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?