1

Having negotiated the Oauth2 maze of tokens and the like, I can get the MailboxSettings from the Outlook REST API using :

https://outlook.office.com/api/v2.0/me/mailboxsettings 

I'm now trying to update the mailboxsettings (autoreply settings) using the Outlook Mail REST API reference sample.

I'm using the c# webclient:

URI = "https://outlook.office.com/api/v2.0/me/mailboxsettings";
data = "{\"@odata.context\":
\"https://outlook.office.com/api/v2.0/$metadata#Me/MailboxSettings\",
\"AutomaticRepliesSetting\": {\"Status\": \"Scheduled\",
\"ExternalAudience\": \"None\", \"ScheduledStartDateTime\":
{\"DateTime\": \"2018-02-20T02:00:00.0000000\", \"TimeZone\":
\"UTC\"}, \"ScheduledEndDateTime\": { \"DateTime\":
\"2018-02-28T02:00:00.0000000\", \"TimeZone\": \"UTC\" },
\"InternalReplyMessage\": \"<html>\n<body>\n<p>I'm at our company's
worldwide reunion and will respond to your message as soon as I
return.<br>\n</p></body>\n</html>\n\", \"ExternalReplyMessage\":
\"<html>\n<body>\n<p>I'm at the Contoso worldwide reunion and will
respond to your message as soon as I
return.<br>\n</p></body>\n</html>\n\" }, \"TimeZone\": \"Pacific
Standard Time\", \"Language\":{ \"Locale\":\"en-US\",
\"DisplayName\":\"English (United States)\" } } ";

wc.UploadString(URI, "PATCH", data);

The last line gives me an exception:

The remote server returned an error: (415) Unsupported Media Type.

I don't know what that means. Any suggestions gratefully received

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63

1 Answers1

1

You need to set the Content-Type header to application/json.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34