<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Account Level API GET Call requiring User-Agent Header in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/account-level-api-get-call-requiring-user-agent-header/m-p/90568#M8342</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;So have to add this:&amp;nbsp; httpClient.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.42.0");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any reason for that?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 12:44:43 GMT</pubDate>
    <dc:creator>unseen007</dc:creator>
    <dc:date>2024-09-16T12:44:43Z</dc:date>
    <item>
      <title>Account Level API GET Call requiring User-Agent Header</title>
      <link>https://community.databricks.com/t5/get-started-discussions/account-level-api-get-call-requiring-user-agent-header/m-p/90568#M8342</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;So have to add this:&amp;nbsp; httpClient.DefaultRequestHeaders.Add("User-Agent", "PostmanRuntime/7.42.0");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any reason for that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 12:44:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/account-level-api-get-call-requiring-user-agent-header/m-p/90568#M8342</guid>
      <dc:creator>unseen007</dc:creator>
      <dc:date>2024-09-16T12:44:43Z</dc:date>
    </item>
  </channel>
</rss>

