microsoft graph api - Cannot create mail subscription error: ServiceUnavailable - microsoft-graph-api

When we were trying to create a email subscription with an email account, we got the ServiceUnavailable error.
POST https://graph.microsoft.com/v1.0/subscriptions
Body: {
"changeType": "created",
"notificationUrl": "***********************",
"resource": "me/messages",
"expirationDateTime":"2019-09-11T18:23:45.9356913Z",
"clientState": "****"
}
Response is
{
"error":{
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: ServiceUnavailable; Reason: Target resource '0003bffd-d62b-a260-0000-000000000000' hosted on database '8cea8e2c-3c39-469c-a9e7-3f0bed47d869' is currently on backend 'Unknown']",
"innerError":{
"request-id": "972e7800-541e-41f9-8792-069ecd564345",
"date": "2019-09-09T23:30:13"
}
}
}
What could be the reason for this kind of error?

Related

Microsoft ToDo Graph API is sending broken JSON

I'm getting the response with invalid JSON (brackets aren't closed) when trying to get the MS ToDo task for the user. Also, API sends HTTP status 200 with that response.
Request/response examples:
https://graph.microsoft.com/v1.0/me/todo/lists/:listID/tasks/:taskID
{
"title": "DELETED",
"createdDateTime": "2020-06-17T18:33:44.3228459Z",
"lastModifiedDateTime": "2020-11-27T11:36:55.8037415Z",
"id": "DELETED",
"linkedResources": [
{
"error": {
"code": "InternalServerError",
"message": "Invalid object within the collection response from workload for navigation property linkedResources with declaring type microsoft.graph.todoTask. Expected a JObject, but got Jtoken type - Null",
"innerError": {
"date": "2021-05-14T03:13:36",
"request-id": "5b9445b0-7405-436a-8179-cac92a8af087",
"client-request-id": "5b9445b0-7405-436a-8179-cac92a8af087"
}
}
}
How can I resolve this issue?

Creating Contact returns ResourceNotFound error

I'm getting an error of ResourceNotFound while integrating and calling POST v1.0/me/contacts:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"date": "2021-03-01T15:45:47",
"request-id": "76062d8a-e541-4a52-ae08-9b196dd8e07d",
"client-request-id": "dd8b8c41-22bb-2b78-c926-3063ef313ba0"
}
}
}
I get the same from Graph Explorer:
Note: token is used, API permissions given.
Can anyone please guide/help on this issue?

Bad Request: Invalid filter clause

I am using POSTMAN to call Microsoft Graph APIs. I am trying to subscribe to presence for multiple users. It is mentioned in document in order to subscribe to changes to multiple user presences use this url :/communications/presences?$filter=id in ({id},{id}...)
Request Url
https://graph.microsoft.com/beta/subscriptions
So this is request body(raw)
{
"changeType": "updated",
"notificationUrl": "https://d3a8ebc3581d.ngrok.io/presence-notify/",
"resource": "/communications/presences?$filter=id in (abcd-efgh-4856-a935-c9a2f685xyz,abcd-efgh-47f8-9d79-eacb0fd6xyz)",
"expirationDateTime": "2020-09-22T07:37:13Z",
"clientState": "secretClientState"
}
I am calling this API on behalf of user i.e i am using UserAccessToken. This is Response:
{
"error": {
"code": "BadRequest",
"message": "Invalid filter clause",
"innerError": {
"date": "2020-09-21T16:24:50",
"request-id": "2cf476f0-2270-417f-a987-5c5bbc92a351",
"client-request-id": "2cf476f0-2270-417f-a987-5c5bbc92a351"
}
}
}
P.S: I have changed first few and last few characters of both the user ids. So it's not an issue.
I'm guessing this isn't documented very clearly, but if you check the filter documentation. You'll see that values actually need to have ' around them.
So if you change your request to the following it should work:
{
"changeType": "updated",
"notificationUrl": "https://d3a8ebc3581d.ngrok.io/presence-notify/",
"resource": "/communications/presences?$filter=id in ('abcd-efgh-4856-a935-c9a2f685xyz','abcd-efgh-47f8-9d79-eacb0fd6xyz')",
"expirationDateTime": "2020-09-22T07:37:13Z",
"clientState": "secretClientState"
}

Creating Subscription through Postman throws error

Creating WebHook for MicrosoftGraph throws error
What is ClientState represents ?
{
"changeType": "updated",
"clientState": "kT]G=3#hClz0rRfOuVr*3UA8V_9UGs4p",
"expirationDateTime": "2019-09-26T15:46:18.835Z",
"notificationUrl": "https://webhooksformicrosoftgraph.azurewebsites.net/api/HttpTrigger1",
"resource": "groups"
}
{
"error": {
"code": "InvalidRequest",
"message": "Subscription validation request failed. Must respond with 200 OK to this request.",
"innerError": {
"request-id": "4f368e23-9a5d-4c72-a2cf-9bbe33f677f4",
"date": "2019-09-23T06:35:20"
}
}
}
We have a great tutorial on setting up your first change notification (web hook). You may want to run through this first
https://learn.microsoft.com/en-us/graph/tutorials/change-notifications
Basically your API that our web hook calls needs to return 200 OK on first registering a subscription for our service to validate your API.

Unable to subscribe to rich notifications in MS Graph

How can I create a subscription with rich notifications in MS Graph?
POST https://graph.microsoft.com/v1.0/subscriptions
{
"resource": "users/{email}/messages?$select=hasAttachments",
"changeType": "created",
"clientState": "415e99b4-73af-454e-93b5-00eb6c3082b9",
"notificationUrl": "https://229c8207.ngrok.io/Notification/Listen",
"includeProperties": true,
"expirationDateTime": "2019-01-16T22:21:56.3942423+00:00"
}
Expected: 202 Created
Actual: 400 Bad Request
{
"error": {
"code": "InvalidRequest",
"message": "Microsoft.Exchange workload is not enabled for rich notifications.",
"innerError": {
"request-id": "7e03b3c9-aa49-4222-b7a7-5fddebc82327",
"date": "2019-01-16T16:47:24"
}
}
}
"Rich notifications" are not yet enabled through Microsoft Graph. We are working on it and will be adding some exciting new capabilities. We cannot provide an ETA at this time, but it is top of our list for this feature area.

Resources