从邮递员到Microsoft Dynamics CRM 365的POST/GET请求 [英] POST/GET request from postman to Microsoft Dynamics crm 365
问题描述
我试图使用Web API创建实体.因此,使用我的实例URL,client_id,client_secret,我可以成功生成访问令牌和刷新令牌.但是,每当我尝试使用该access_token发出任何发布请求时,我都会获得401(未授权)状态.
我试图像这样从邮递员创建新实体:
网址:https://myurldomain.crm5.dynamics.com/api/data/v9.0/accounts
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
标题:
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
}
在发送请求时,我不断收到401未经授权的回复. 有什么建议吗? 我正在关注他们的 API
While send request, I constantly get 401 unauthorized response. Any suggestion please? I am following their API
推荐答案
按照MS文档设置Postman环境&使用相同的代码执行操作:将Postman与Dynamics 365 Web API配合使用
Follow the MS documentation to setup the Postman environment & using the same to perform operations: Use Postman with the Dynamics 365 Web API
设置邮递员环境时,请确保在Azure AD登录挑战弹出窗口中使用CRM用户凭据,该弹出窗口至少具有一个安全角色,涵盖CRM中的必要特权.如果您能够在CRM UI中创建帐户记录,那么也可以在Postman中使用您的凭据.
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.
要管理在Postman中用于连接的任何CRM用户的角色,请检查设置"-安全性"-用户"下CRM中的用户"配置文件.如果需要,请从销售人员角色开始.
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.
获取令牌是O365&适用于任何有效AD用户的AAD,但API请求使用该令牌&向CRM在线平台发布网络api,CRM安全模型将在其中启动和运行;授权数据访问.
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.
这篇关于从邮递员到Microsoft Dynamics CRM 365的POST/GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!