Access Token Not Recognised

Hi @Ewa_Lipinska,

When I am trying to get single contact details, it shows me an error “Access Token Not Recognised”. but with the same access toke I am getting everything like categories, list of contacts, company profile etc.

I am using the URL “https://api.freeagent.com/v2/contacts/85086”, please let me know if something is missing. my c# coding is as below.

var nclient = new HttpClient();
nclient.DefaultRequestHeaders.TryAddWithoutValidation(“Content-Type”, “application/x-www-form-urlencoded”);
nclient.DefaultRequestHeaders.Add(“accept”, “application/json”);
nclient.DefaultRequestHeaders.Add(“user-agent”, “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36”);
nclient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(“Bearer”, access_token);
var nreq = new HttpRequestMessage(HttpMethod.Get, “https://api.freeagent.com/v2/contacts/85086”);
var nres = await nclient.SendAsync(nreq);

Hi @nishitcaax,

Thanks for your question. I must admit it’s not outright obvious to me why your requests have failed – I’ve had a stab at getting a single contact using your code and was able to get a successful response for a contact in my test account. :thinking:One thing that comes to mind is that perhaps your access token expired shortly before you tried making those requests – as you can see in our documentation here, access tokens are valid for one hour only. I notice you’ve not tried retrieving the contact since shortly after posting on the forum; could you give it another shot with a fresh access token and see if it works this time round?

Best wishes,

Ewa

Thanks @Ewa_Lipinska, it has been resolved.

1 Like