0
votes

I am trying to create webhook subscription following this document: https://docs.microsoft.com/en-us/graph/webhooks

However, when I try to POST to microsoft graph it gives me this error: "code": "", "message": "No HTTP resource was found that matches the request URI 'https://subscriptionstore.windows.net/1.0/subscriptions'.", "innerError": { "request-id": "10cd5a1d-56a7-44d4-9f4d-51516c7ab69c", "date": "2019-06-10T10:54:12"

But I didn't POST to that URL, I POST to this one: https://graph.microsoft.com/v1.0/subscriptions

this is my code in python django-rest

outlook_token = settings.outlook_token
request_url = "https://graph.microsoft.com/v1.0/subscriptions"

headers = {"Authorization": f"Bearer {outlook_token}"}

expiration_date = datetime.utcnow() + timedelta(minutes=4000)
print(expiration_date)
expiration_date = expiration_date.strftime("%Y-%m-%dT%H:%M:%SZ")

notification_url = (
    "https://9d065f52.ngrok.io/api/v1.0/user-calendar-settings/calendar-webhook"
)

payload = {
    "changeType": "created,updated,deleted",
    "notificationUrl": notification_url,
    "resource": "/me/events",
    "expirationDateTime": expiration_date,
    "clientState": "SecretClientState",
}

response = requests.patch(url=request_url, headers=headers, json=payload)
1

1 Answers

0
votes

Sorry, I did a PATCH instead of POST that was the problem.