cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Account Level API GET Call requiring User-Agent Header

unseen007
New Contributor

We recently Enabled Unity Catalog so using Account Level API and little stuck on a GET call. For some reason, just the GET call requires a User-Agent header while POST, PUT, PATCH.. all work without it. For workspace API, there was no need for User-Agent Header GET call, with Account Level API, getting 400.

So have to add this:  httpClient.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.42.0");

 

 

var httpClient = _httpClientFactory.CreateClient("AdbClient");
var contentType = "application/scim+json";
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

HttpResponseMessage response;

switch (httpMethod.Method)
{
    case "GET":
        // Only needed for Account Level API Call
        httpClient.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.42.0");
        response = await httpClient.GetAsync(endpoint);
        break;
    case "POST":
        HttpContent postBody = new StringContent(contentBody);
        postBody.Headers.ContentType = new MediaTypeHeaderValue(contentType);
        response = await httpClient.PostAsync(endpoint, postBody);
        break;
    case "PUT":
        HttpContent putBody = new StringContent(contentBody);
        putBody.Headers.ContentType = new MediaTypeHeaderValue(contentType);
        response = await httpClient.PutAsync(endpoint, putBody);
        break;

 

Any reason for that? 

0 REPLIES 0

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now