POST/GET request from postman to Microsoft Dynamics crm 365

*爱你&永不变心* 提交于 2019-12-23 02:29:08

问题


I was trying to create entity using Web API. So using my instance url, client_id, client_secret I can successfully generate access token and refresh token. But whenever I try to make any post request using that access_token, I get 401(unauthorized) status. I was trying to create new entity from postman like this: url: https://myurldomain.crm5.dynamics.com/api/data/v9.0/accounts

headers:

POST /api/data/v9.0/accounts HTTP/1.1
Host: myinstancename.crm5.dynamics.com
Content-Type: application/json; charset=utf-8  
Authorization: Bearer  mytoken
OData-Version: 4.0
OData-MaxVersion: 4.0
Accept: application/json

[copied from postman code section]
Body:

{
    "name": "Sample Account",
    "creditonhold": false,
    "address1_latitude": 47.639583,
    "description": "This is the description of the sample account",
    "revenue": 5000000,
    "accountcategorycode": 1
}

While send request, I constantly get 401 unauthorized response. Any suggestion please? I am following their API


回答1:


Follow the MS documentation to setup the Postman environment & using the same to perform operations: Use Postman with the Dynamics 365 Web API

When you setup the Postman environment, make sure you use the CRM user credentials in Azure AD signin challenge popup, which has minimum of one security role covering the necessary privileges in CRM. If you are able to create an Account record in CRM UI, then use your credentials in Postman too.

To manage roles for any CRM user you are using to connect in Postman, check that User profile in CRM under Settings - Security - Users. Start with Sales person role if you want.

Assign a security role to a user

Getting a token is first part handled by O365 & AAD for any valid AD user, but the API request uses that token & issue the web api to CRM online platform where the CRM security model will kick in & authorize the data access.




回答2:


Latest version of postman added the support for NTLM authentication(although its still a beta version). Are you using NTLM authentication from postman to call Crm Dynamics web api. If not try using that and it asks for Domain name inaddition to username and password. Hopefully this helps with your authentication problems.



来源:https://stackoverflow.com/questions/54566738/post-get-request-from-postman-to-microsoft-dynamics-crm-365

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!