microsoftgraph/aspnet-webhooks-rest-sample

Microsoft Graph - Asp.net Webhooks Rest Sample - Subscription response error

Closed this issue · 2 comments

Hi,

I am following the steps mentioned in the given forum: https://github.com/microsoftgraph/aspnet-webhooks-rest-sample.

I am using ngrok for the localhost endpoints. I have updated the keys like client id, client secret key, notificaiton url in the web.config. The app is registered in Azure Active Directory.

While sending request to the microsoft graph to subscribe to users email,
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, subscriptionsEndpoint);
Subscription subscription = new Subscription
{
Resource = "me/mailFolders('Inbox')/messages",
//Resource = "me/events",
ChangeType = "created",
NotificationUrl = ConfigurationManager.AppSettings["ida:NotificationUrl"],
ClientState = Guid.NewGuid().ToString(),
//ExpirationDateTime = DateTime.UtcNow + new TimeSpan(0, 0, 4230, 0) // current maximum timespan for messages
ExpirationDateTime = DateTime.UtcNow + new TimeSpan(0, 0, 15, 0) // shorter duration useful for testing
};

I am getting below error:
An error occurred while processing your request.
NotFound
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: NotFound; Reason: Not Found]",
"innerError": {
"request-id": "de7d32c4-b634-4193-b06e-adb614b86ec7",
"date": "2018-04-09T18:02:45"
}
}
}

When i inspect in the ngrok web interface: http://127.0.0.1:4040/inspect/http
I see below response:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: plain/text; charset=utf-8
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcV29ya1xhc3BuZXQtd2ViaG9va3MtcmVzdC1zYW1wbGUtbWFzdGVyXGFzcG5ldC13ZWJob29rcy1yZXN0LXNhbXBsZS1tYXN0ZXJcR3JhcGhXZWJob29rc1xub3RpZmljYXRpb25cbGlzdGVu?=
X-Powered-By: ASP.NET
Date: Mon, 09 Apr 2018 18:00:13 GMT
Content-Length: 48

NjE3MTc4MjItZDllNi00ZDcwLThiZDYtYmU1YTlkMDUzZTAz - This is the validation token

How to fix this error ? What am i doing wrong in this ?

From the error, it makes me think that maybe the user that you're logged in as doesn't have an Exchange Online mailbox?

MrJoy commented

How do we determine via the API if the user has an Exchange Online mailbox? I've run into that issue (and, separately, the error in this ticket), but I haven't found a clear way to determine if a user I discovered in Azure AD has an Exchange Online mailbox or not -- short of just trying to access it and checking the error I get back. Apologies if I'm being obtuse and not seeing something clearly documented, but I've been over the docs a bunch of times and haven't found anything.