1

I subscribed to Dynamics 365 with a trial version. I can connect from office 365 to the url of the Crm service in Internet Explorer as:

     https://myorg.crm4.dynamics.com

Also I can access Odata as:

   https://myorg.crm4.dynamics.com/api/data/v8.2/accounts

I try to connect to the Odata service using Postman. I created an application in azure with permissions to crm as described here

I get an access_token, so this insure that the resource is valid.

I tried to do GET request to the resource using this valid access_token but postman respond with 401 Unauthorized

I read tens of pages but it can't help. I suspect (but not sure) that odata service may not available in the trial version for developers.

The Question:

Why I get this error although I have a valid access_token, what I missed?

Is Odata service unavailable when using the trial license?

M.Hassan
  • 10,282
  • 5
  • 65
  • 84

1 Answers1

0

I also faced a similar issue while connecting to the MS Dynamics365 CRM from a middleware client through WebAPIs and here was the scenario:

  1. I tested the connectivity with PostMan and it was working fine- I used the Authorization Code and Password Credentials Grant Type methods.

  2. When I ported the connectivity config to the target middleware application, we found the Authorization Code grant type was ineffective for us as it was asking a user to sign in in our case.

  3. I configured the Password Credentials grant type which eliminated the manual intervention of signing to the user account.

  4. I successfully got Auth Token but the API call to the secured resources was throwing a 401 error. It was really troublesome and led to reading all the support and troubleshooting articles/blogs/videos.

  5. I did a root cause analysis of my application and we found that the token we received wasn't sent properly, the app was adding some extra spaces in the token string and that was causing the 401 issue.

We trimmed the token variable and fixed the issue and Boom!!

So sometimes troubleshooting should be done end to end focusing on the tiny components especially when we are calling the APIs over a network.

Feel free to reach out for any assistance or queries.

Cheers!!

#401 unauthorized #D365-Integration-WebAPIs #OAuth2.0