cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group