Server side application at startup logs in and all requests are through that application, no user /subscriptions

Mark Spritzler 0 Reputation points
2025-01-29T15:50:31.73+00:00

So there is only one Permission for Subscriptions Subscription.Read.All, and it is a delegated permission. We have added it and had Admin access granted. I am able to run the GET to get all current subscriptions, I am able to POST a new subscription, but I get access errors on GET subscriptions/{subscriptionId} and on DELETE subscriptions/{subscriptionId}. I followed the code samples in the documentation and also in the Graph Explorer.

I also noticed that the documentation says that the request to POST will throw an exception if there is already a subscription for that source item already. But yet we have now 15 subscriptions for the same Outlook Inbox. Basically each time we start up the server it is adding a new one, where that POST should throw an exception. Which means we get called 15 times and therefore store the attachments and .eml file into Sharepoint 15 times and create 15 rows in our database for the same email, so now duplicate data we don't want.

"Duplicate subscription behavior

Duplicate subscriptions aren't allowed. When a subscription request contains the same values for changeType and resource that an existing subscription contains, the request fails with an HTTP error code 409 Conflict, and the error message Subscription Id <> already exists for the requested combination."

The changeType and resource is always identical for each POST request we make so we should be getting a 409, but we aren't we are getting another new subscription added to the same changeType and resource

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,036 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Saranya Madhu-MSFT 1,425 Reputation points Microsoft Vendor
    2025-01-30T10:02:13.7633333+00:00

    Hi Mark Spritzler,

    Thanks for reaching out to Microsoft!

    For subscriptions related [Inbox messages](https://learn.microsoft.com/en-us/graph/api/subscription-list?view=graph-rest-1.0&tabs=http#:~:text=Sites.ReadWrite.All-,message,Mail.Read,-offerShiftRequest%0A(/teams/%7Bid), the following permissions are required for delegated: Mail.ReadBasic ,Mail.Read, Subscription.Read.All

    Before creating a new subscription, list all existing subscriptions using the following endpoint:

    GET /subscriptions
    

    This will help you check if a subscription already exists for the same changeType and resource.

    Get specific subscription, GET /subscriptions/{subscriptionId}, if you find duplicate subscriptions with the same changeType and resource, you can delete them.

    If the issue persists, I recommend you raise a support case with Microsoft Graph, a Support Engineer will be able to look into this issue and assist you better. You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.