I was trying out Microsoft Dynamics 365 (v9.0) Web APis.
I was able to generate access token but yet my api call is failing.
I am using adal
for python
from adal import AuthenticationContext
import requests
api = 'https://xxxxxx.crm8.dynamics.com/api/data/v9.0/'
auth_context = AuthenticationContext('https://login.microsoftonline.com/xxxxxx.com')
token = auth_context.acquire_token_with_client_credentials(
resource='https://xxxxxx.com/0d74ff2f-d7d2-46f4-a3c3-fb4f6d49aa51',
client_id='6e859f06-0d88-413f-a3fe-1ae12cc7350d',
client_secret='abigclientsecret')
print(token)
at = 'Bearer ' + token['accessToken']
headers = {'Authorization' : at,
"Content-Type" : "application/json; charset=utf-8",
'OData-MaxVersion' :'4.0',
'OData-Version' :'4.0',
'Accept' : 'application/json'}
response = requests.get("https://xxxxxx.api.crm8.dynamics.com/api/data/v9.0/contacts", headers=headers)
print(response)