RE: WEB API Authentication: 401 Unauthorized
Hello,
Authenticating with the WebApi works the same way for GET, POST, PATCH and all other verbs.
Getting a 401 on your request is pretty strange, when that same token does work on a different request. It might be that your token has just expired? Access tokens have a pretty short lifespan (by design)
Always get your access token first, via Azure AD (login.microsoftonline.com) and make sure it it's valid before you do every request, if not refresh it.
Send the access token in the 'Authorization' header on every request, GET, POST, or other.
GET example:
curl -X GET \
https://organizationname.crmX.dynamics.com/api/data/v8.2/accounts \
-H 'authorization: Bearer eyJ0eXAiOiJKV...'
POST example:
curl -X POST \
https://organizationname.crmX.dynamics.com/api/data/v8.2/accounts \
-H 'authorization: Bearer eyJ0eXAiOiJKV...' \
-H 'content-type: application/json' \
-d '{ "name":"New Account Record" }'
Hope this helps you on your way!