Hi everyone,
I am trying to retrieve accounts data through WeAPI via Dynamics 365 On Premise which has IFD authetication. I am able to get the access token through adfsurl/.../token but when I pass the token and try to get some data using WebAPI, I am facing 401 unauthorized error. Here is my code :
var res = _httpClient.PostAsync(new Uri("">adfsurl/.../token"), content);
var respo = res.Result.Content.ReadAsStringAsync().Result;
accesstoken = JObject.Parse(respo).GetValue("access_token").ToString();
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer",accesstoken);
var response = _httpClient.GetAsync("">crmurl/.../WhoAmI").Result;
I am getting this error on the above line of code (StatusCode: 401, ReasonPhrase: 'Unauthorized')
Any help is highly appreciated. Thank you.