Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Dynamics365 - Rest API - Credential Access

Posted on by 5

Hello,

 I am trying to build some APIs to populate or update contact records in our CRM. we generated credentials in our Azure AD environment. Were able to use the client/secret keys to generate our bearer token, but the API calls are getting a 401 error. I was hoping you had some insights into what permissions are required for that endpoint credential to access the CRM platform to run Get/Post/Patch calls. When we created the endpoint we had to give it roles/assignments but we weren't sure what exactly to give it. I think this is the root of the 401 error.

Example API is as follows:


customer.crm.dynamics.com/.../contacts

customer.api.crm.dynamics.com/.../candidates

customer.crm.dynamics.com/.../candidates

Hoping to get insights into what are the appropriate roles/responsibilities in AZURE AD to run these types of commands.

Thank you,

Ted Woods

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Dynamics365 - Rest API - Credential Access

    then try if the request works inside Postman, if works inside Postman then contact the support of OneTrust (because the problem looks like not connected to Dynamics). If doesn't work inside Postman it means the Bearer token is not correct.

  • TedWoods1848 Profile Picture
    TedWoods1848 5 on at
    RE: Dynamics365 - Rest API - Credential Access

    1) Bearer token generates properly

    2) there is prefix ahead of candidates, I was anonymizing our API call.

    Thanks

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Dynamics365 - Rest API - Credential Access

    you can use any software you want to call the API, but you have two problems:

    1) the bearer token needs to be valid, and you can verify it with postman

    2) the query to Dynamics needs to be valid, in your example that endpoint I am 99,99% sure that is not valid because "candidates" endpoint does not exists (maybe is prefix_candidates) and for that you can use Dataverse REST Builder to build the query.

    hope it helps

  • TedWoods1848 Profile Picture
    TedWoods1848 5 on at
    RE: Dynamics365 - Rest API - Credential Access

    I am using OneTrust our Privacy Management Solution:

    HTTP operation failed invoking https://***Customer***.api.crm.dynamics.com/api/data/v9.2/candidates with statusCode: 401

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Dynamics365 - Rest API - Credential Access

    are you sure you did all the steps for the clientid-clientsecret? including the assignment of a security role? here you can find a tutorial

    benediktbergmann.eu/.../

    where are you getting the 401 error?

    if inside postman try to generate the request using my tool Dataverse REST Builder and after export the collection to postman, when you export you can set the authentication to your clientid-clientsecret

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