[英]Update MailboxSettings fails with Unsupported Media Type (415)
在協商了 Oauth2 令牌迷宮等之后,我可以使用以下命令從 Outlook REST API 獲取MailboxSettings
:
https://outlook.office.com/api/v2.0/me/mailboxsettings
我現在正在嘗試使用 Outlook Mail REST API 參考示例更新mailboxsettings
設置(自動回復設置)。
我正在使用 c# 網絡客戶端:
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);
最后一行給了我一個例外:
遠程服務器返回錯誤:(415) 不支持的媒體類型。
我不知道那是什么意思。 感謝收到任何建議
您需要將Content-Type
標頭設置為application/json
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.