User agent http header not set


#1

Hi,

I want to get company details, it gives me a message “User agent http header not set”.

Is there something like tenant id in freeagent api?

My code is as below.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var nclient = new HttpClient();
nclient.DefaultRequestHeaders.TryAddWithoutValidation(“Content-Type”, “application/x-www-form-urlencoded;”);
nclient.DefaultRequestHeaders.Add(“accept”, “application/json”);
nclient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(“Bearer”, new_access_token);
var nreq = new HttpRequestMessage(HttpMethod.Get, “https://api.sandbox.freeagent.com/v2/company”);
var nres = await nclient.SendAsync(nreq);
string nrep = await nres.Content.ReadAsStringAsync();

Thanks


#2

Hi @Ewa_Lipinska,

Can you please help me for the same?

Thank you


#3

Hi @nishitcaax,

Thanks for your patience – I’m afraid we don’t have anyone monitoring the API Forum on weekends. We don’t have any specific requirements as to the contents of your User-Agent header – and we certainly don’t expect it to contain a unique user identifier (which is what I understand the tenant id to be in some of Microsoft’s systems).

The User-Agent header usually contains information about the application/operating system/vendor/version of the agent making a request on behalf of a user. Could you try setting this header as the error message you’re receiving would suggest and see how you get on?

Best wishes,

Ewa


#4

Thank you @Ewa_Lipinska