Unable to create a subscription using /subscriptions endpoint

Mahesh Kurucheti 51 Reputation points
2023-12-05T07:26:07.35+00:00

Hi Team,

I have gone through the below documentation and trying to create subscription, but getting an error, please find the screenshots below:

https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http

The notification URL used is publicly available.User's image

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,383 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AsithwMSFT 1,420 Reputation points Microsoft Vendor
    2023-12-10T00:36:34.2833333+00:00

    @Mahesh Kurucheti

    have you noticed notification URL validation as mentioned in here in your documentation ?

    This error trends to occure due to lack of notification url validation..

    when you create subscription, Microsoft graph validates your notification URL by sending some token such as this

    POST https://{notificationUrl}?validationToken={opaqueTokenCreatedByMicrosoftGraph}

    therefore, you need to separately handle that request from your notification endpoint.

    in this scenario, take the value of validationToken and return it like below.

    if (Request.QueryString["validationToken"] != null)
                {
                    var token = Request.QueryString["validationToken"];
                    return Content(token, "text/plain");
                }
    

    make sure return content type "text/plan"

    find this samples for more details

    link

    link2

    link3

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

    0 comments No comments