Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

CRM Online Web API Error 401 : Unauthorized : Access is denied

$
0
0

Hi All,


I have been trying to test the CRM Online Web API, to verify if it could be a good solution for my PHP public web site to input data into CRM.

The goal here is to create a new Contact in CRM whenever an (unidentified) user submits a form in the web site.

For testing purposes, I am using REST/JSON requests sent via Postman to try to achieve this.

I went through a lot of pain to register my web site in Azure AD, and to post a JSON request to login.microsoftonline.com/<my_tenant_id>/oauth2/token that would allow me to get an access token, by the "client_credentials" method.

I am finally able to get tokens that look quite good :

{"token_type": "Bearer","expires_in": "3600","expires_on": "1458152686","not_before": "1458148786","resource": "xxxxxx.crm4.dynamics.com/.../v8.0","access_token": "iOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJodHRwczovL2tsZWVjcm0uY3JtNC5keW5hbWljcy5jb20vYXBpL2RhdGEvdjguMC8iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8zZDExOTNiNS1iMzNjLTRhOTEtY_ELUUQGw5PF8OSPsFoNh6SPUgnFoqtbHL4dCWnyuLxlbyvMWuQNWotMRJAhQGo7nRmQYSYSHX62XW76ArlqKAvhyXTlhn68ma5ZFx_ohMBGR4_W4FrgNaZC5e7OQ2QNAl8wq33vrzi7OFEjHRHPygt__VB7rCybqBbLIpFZPcZqoiy1johpAEMpgK332VLoH5jBBa5kf39TWI7Y5FlXtQ"
}

I used a token to post a sample JSON request that would create an account to https://xxxxxx.crm4.dynamics.com/api/data/v8.0/accounts but I keep getting a 401 error (Unauthorized : Access is denied").

It looks like the token is good, because if I alter it, I get another error indicating that the token is incorrect.

I have to be close to a solution here but I can't figure it out. What am I missing ?


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>