Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dynamic 365 web api integration outside the crm

Posted on by Microsoft Employee

I am call dynamic 365 api from outside the crm. I am following below document however i am getting authentication 401 error even after giving the correct token. I am follwoing below steps

curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlZXVkljMVdEMVRrc2JiMzAxc2FzTTVrT3E1USIsImtpZCI6IlZXVkljMVdEMVRrc2JiMzAxc2FzTTVrT3E1USJ9.eyJhdWQiOiIwMDAwMDAwMi0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jZWUzMDZlYS0xMzY2LTQ2ZDItYmEyMS01ZGZkOTMzODVhZGIvIiwiaWF0IjoxNTAyNDQyNzc5LCJuYmYiOjE1MDI0NDI3NzksImV4cCI6MTUwMjQ0NjY3OSwiYWlvIjoiWTJGZ1lKQXlONTNlMEsyME1aWHIveHlGN3BkOEFBPT0iLCJhcHBpZCI6Ijk2YWQzNjQ4LTdhNjQtNDYyZi04YjU0LTEwN2UxNDdmZDcyOCIsImFwcGlkYWNyIjoiMSIsImlkcCI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2NlZTMwNmVhLTEzNjYtNDZkMi1iYTIxLTVkZmQ5MzM4NWFkYi8iLCJvaWQiOiJlNDJlNjgyYS0yMzc1LTQyZDUtYjc1OC1iOTk0MWM0YmY5MjIiLCJzdWIiOiJlNDJlNjgyYS0yMzc1LTQyZDUtYjc1OC1iOTk0MWM0YmY5MjIiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiJjZWUzMDZlYS0xMzY2LTQ2ZDItYmEyMS01ZGZkOTMzODVhZGIiLCJ1dGkiOiJ3YUhMWDB0UXZrS2xOVVQ5alJ3cEFBIiwidmVyIjoiMS4wIn0.ikd6qZyo4VfZe0b6oJs2zL5tV-5sK8Cj36ppXSojPcRwx0dkT0wCXqgeqcWPQsTIkVpAznYKWKjk7VMH7k5Tooem3zSVMzHeMJb-q_uHB6jKTmorDpUYYjxUPxOI_XpTRfsDlSHoMu_o_yVzV0hy0DR6dqLyBfNrSwVxMw7C6TfwViIlp7p9CfwR4zVNg8OL7AtHUF-StW6J-Zw97uc83Ef7tkSyzdT1GNM0HA1MrkbLlrlBfSlayvfX3FdUNDoZw5L-kx8H7vz39YCOXc9DiteMtj2UwARaa58BmDtpyHBHqJIZkf_Gg5tlc212wjZqQYYW0RaZi4XR4u3rgp8RVQ" 'fusioncx.api.crm8.dynamics.com/.../v8.2'

Response :

HTTP Error 401 - Unauthorized: Access is denied

Please suggest how can i resolve it.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamic 365 web api integration outside the crm

    Hello,

    Have you created an "Application user" in Dynamics 365 for the Azure application.

    Because you have the access token, but for the execution of Dynamics 365 API you need to have an "Application user" in MSD in the first place.

    Thank you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamic 365 web api integration outside the crm

    I am having similar issue, I am trying to setup Postman.

    1. I registered app on Azure AD with a key

    2. Got New Access Token using client credentials using Postman

    3. Using the Access Token generated in step2 when I make a GET call on WebAPI to retrieve one of my incident status I am getting HTTP Error 401 - Unauthorized: Access is denied.

    FYI - I verified the WebAPI endpoint works fine when I access through browser. I got proper json response see below (I masked my instance name with xxxx in the response below)

    {"@odata.context":"xxxxx.crm.dynamics.com/.../v9.0$metadata#incidents(statecode,statuscode)","value":[{"@odata.etag":"W/\"1353708\"","statecode":0,"statuscode":1,"incidentid":"013046d0-e7b1-e811-a98c-000d3a161089"}]}

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: Dynamic 365 web api integration outside the crm

    Have you registered the app in Azure AD? This issue will occur if App is not registered or your secret key is mismatched.

    Thanks,

    Prateek

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Dynamic 365 web api integration outside the crm

    Can you post your code, and how you derive the token ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans