0
votes

I am attempting to make use of the Outlook Notification REST API as described here (Microsoft Outlook Notifications REST API) but I am getting an error when calling the subscribe REST service.

The response I am getting is:

{"error":{"code":"ErrorAccessDenied","message":"Access to OData is disabled."}}

The following is my request header and the JSON body I am sending in the request.

Headers:

POST https://outlook.office.com/api/v2.0/me/subscriptions HTTP/1.1
client-request-id: d138d432-9b57-409f-80de-3a5ae62cb67c
Accept: text/*, application/xml, application/json; odata.metadata=minimal
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJodHRwczovL291dGxvb2sub2ZmaWNlMzY1LmNvbS8iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jNTEyZmZkMS01ODFkLTRkYzAtYTY3Mi1mYWVlMzJmNjM4N2MvIiwiaWF0IjoxNDUwODg0MDIxLCJuYmYiOjE0NTA4ODQwMjEsImV4cCI6MTQ1MDg4NzkyMSwiYWNyIjoiMSIsImFtciI6WyJwd2QiXSwiYXBwaWQiOiJkMTM4ZDQzMi05YjU3LTQwOWYtODBkZS0zYTVhZTYyY2I2N2MiLCJhcHBpZGFjciI6IjEiLCJmYW1pbHlfbmFtZSI6IkpvcmRhbiIsImdpdmVuX25hbWUiOiJLYXRpZSIsImlwYWRkciI6IjY4LjE4Ny4xMDcuMjE4IiwibmFtZSI6IkthdGllIEpvcmRhbiIsIm9pZCI6ImQwZmFlNWRmLTc5NmEtNDc4Ny1hZDcxLTVhMDFjY2EyMWM3YiIsInB1aWQiOiIxMDAzM0ZGRjg5MzE5QTYzIiwic2NwIjoiQ2FsZW5kYXJzLlJlYWRXcml0ZSBDb250YWN0cy5SZWFkV3JpdGUgTWFpbC5SZWFkV3JpdGUiLCJzdWIiOiJrQ1FtSkpWY2ZSY3ljTjZVY2t2Z29NWVVmb09YcU9mSHpsWllLQnRsLWdvIiwidGlkIjoiYzUxMmZmZDEtNTgxZC00ZGMwLWE2NzItZmFlZTMyZjYzODdjIiwidW5pcXVlX25hbWUiOiJLYXRpZUpAb2F1dGhwbGF5Lm9ubWljcm9zb2Z0LmNvbSIsInVwbiI6IkthdGllSkBvYXV0aHBsYXkub25taWNyb3NvZnQuY29tIiwidmVyIjoiMS4wIn0.G2OLoOYbN_WhnhXSwwwgbpjcBJxnZcUYaFvKdFicuIB1h6SxcnfKye27jXnte1c9z33CYA-adzGU0yNem6y45KdPTuOF5FuctBlyBaFU0QFOq3Q1iYS0IEwkyAXy242BpXSFojMlnnAmOJLyNiE47zDV46Omw7wzD0TPGXsOZFVePUumBni81_7J_n-nwut075oXf02uU7CIt1k5Hs2FsQLJyCL6WdjSK7SkJGfeuY4RPtuNhB9WyJa82z45OZlpzz188eJpTGt5l99ou_8_oxyRH_qeHdCbmyK6llG-4LkNwhJP_bzQIVLVbkzV10SnQ8WTqfjoL5y6LFto1IRJ5Q
User-Agent: RestSharp/105.2.3.0
Content-Type: application/json
Host: outlook.office.com
Content-Length: 291
Accept-Encoding: gzip, deflate

{
  "@odata.type": "#Microsoft.OutlookServices.PushSubscription",
  "Resource": "https://outlook.office.com/api/v2.0/me/messages",
  "NotificationURL": "http://*****.net/Outlook/Notifications",
  "ChangeType": "Created",
  "ClientState": "36228645-58b5-4d73-98a6-1b9ac535680f"
}

And the following is the response I am receiving from the REST service, including the headers:

HTTP/1.1 403 Forbidden
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Server: Microsoft-IIS/8.5
Set-Cookie: ClientId=EDBPITZ7TEECEWYFG31KGA; expires=Thu, 22-Dec-2016 15:25:29 GMT; path=/; secure; HttpOnly
Set-Cookie: exchangecookie=3c51c6fccc55495697be99b4847c5c0b; expires=Fri, 23-Dec-2016 15:25:29 GMT; path=/; HttpOnly
Set-Cookie: ClientId=EDBPITZ7TEECEWYFG31KGA; expires=Thu, 22-Dec-2016 15:25:29 GMT; path=/; secure; HttpOnly
request-id: dd22c3f3-a88f-44e4-8308-e419efbdc2e3
X-CalculatedBETarget: CY1PR08MB1801.namprd08.prod.outlook.com
X-BackEndHttpStatus: 403
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-DiagInfo: CY1PR08MB1801
X-BEServer: CY1PR08MB1801
X-Powered-By: ASP.NET
X-MSEdge-Ref: Ref A: 84C683CD88D342739FD51653EF47C087 Ref B: D96A9648900FF06347DE5298F4D86287 Ref C: Wed Dec 23 07:25:29 2015 PST
Date: Wed, 23 Dec 2015 15:25:29 GMT

4f
{"error":{"code":"ErrorAccessDenied","message":"Access to OData is disabled."}}
0

I am kind of stuck at this point. I have a valid Access Token and am I using a Sandbox user to try and test this with (test user retrieved from https://oauthplay.azurewebsites.net/). Not sure what else to try. Thanks for any help that can be provided!

1

1 Answers

0
votes

Sandbox user (and its corresponding mailbox) is restricted to the sandbox web app. Please try another user and check if you get the same error.