2

I'm currently moving from Outlook API to Microsoft Graph API and when I try to subscribe to push notifications for calendars and events as I did for Outlook and I get an error:

{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
  "request-id": "130ef895-4741-472e-9155-73fcb38a487f",
  "date": "2017-07-14T11:40:11"
}
}
}

To authenticate I use end-point:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize

When I send a request to:

https://graph.microsoft.com/v1.0/subscriptions

{
"id": null,
"resource": "users/me/events/calendars/{calendarId}/events",
"notificationUrl": "https://myapp:8080/MyService/notifications/",
"clientState": null,
"@odata.type": null,
"@odata.id": null,
"@odata.context": null,
"changeType": "created,updated,deleted",
"expirationDateTime": "2017-07-19T11:40:10Z"
}

I found several cases with the same error, but they were totally in a different area(not subscriptions). What can be wrong here? I tried to follow this question: "Resource not found for the segment" using Graph subscription beta , However, the solution doesn't work in my case.

dvelopp
  • 4,095
  • 3
  • 31
  • 57
  • 1
    Have you tried omitting all of the fields you are setting to null in the payload? So basically only send `resource`, `notificationUrl`, `changeType`, and `expirationDateTime`? – Jason Johnston Jul 14 '17 at 13:06
  • Thanks! That helps with "resource": "me/calendars/{calendarId}/events", but when I try to subscribe to changes in calendars(calendar added/deleted/updated), still have the same problem and the same message. I tried resources: me/calendars and me/events. According to the doc it should work: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/subscription_post_subscriptions – dvelopp Jul 14 '17 at 13:12
  • Can you update your question with the problem request? – Jason Johnston Jul 14 '17 at 13:37
  • The problem was that in the second request I had not deleted one of the null fields. Thanks for the answer. You might add it as an answer and I will accept it. – dvelopp Jul 14 '17 at 13:39

2 Answers2

2

Remove all of the fields in the payload that you set to null. Make your payload like this:

{
  "resource": "users/me/events/calendars/{calendarId}/events",
  "notificationUrl": "https://myapp:8080/MyService/notifications/",
  "changeType": "created,updated,deleted",
  "expirationDateTime": "2017-07-19T11:40:10Z"
}
Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
1

From your HTTP response, can you give me the X-BEServer HTTP response header value along with the request id and date time for one of these null ref error responses? That way I can pull logs and see what is going on.