I am using Microsoft graph API and trying to create a subscription on the Microsoft developer portal.
https://graph.microsoft.com/v1.0/subscriptions I am hitting this URL with post request call as shown below
`
import requests
access_token = "testtoken"
subscription_data = {
"changeType": "created,updated",
"notificationUrl": "WEBHOOK URL",
"resource": "me/contacts",
"expirationDateTime": '2023-01-16T16:58:00.0000000Z'
}
headers = {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/xml'
}
try:
response = requests.post(f'https://graph.microsoft.com/v1.0/subscriptions', json=subscription_data, headers=headers)
except Exception as e:
print("error")
Above code is giving wrong message response as
`{
"error": {
"code": "InvalidRequest",
"message": "Could not process subscription creation payload. Are all property names spelled and camelCased properly?Also are the dateTimeOffest properties in a valid internet Date and Time format?",
"innerError": {
"date": "2023-01-14T19:09:17",
"request-id": "6d50105e-08b1-494d-8400-5fc32909a8d1",
"client-request-id": "c89e988f-783b-daf5-7d95-677002b0c22d"
}
}
}
`
As you see all property are in camelcase and date format is also in 8601 iso format, still getting errors and not able to create a subscription . I also saw similar problem faced and discussed here https://github.com/microsoftgraph/microsoft-graph-docs/issues/3041 however this is also not giving explanations how to solve the problem
resourceparameter name has a wayward newline in it. See how the"is on the next line? It should be"resource": "me/messages",, all on the same line.