0
我正在嘗試使用Outlook 365 API回覆所有電子郵件。關注this tutorial。按照教程,全部答覆,我們只需要輸入Commnet
但是當我嘗試這樣做,它給Bad Request
錯誤 -如何向Outlook 365 API發送POST請求回覆全部
"error": {
"code": "ErrorInvalidRecipients",
"message": "At least one recipient isn't valid., A message can't be sent because it contains no recipients."
}
我想下面的方法來做到這一點。
public string EmailReplyAll(AuthenticationResult result, string uriString, string msgBody)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uriString);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
EmailReplyAll replyAll = new EmailReplyAll();
replyAll.MsgBody = msgBody;
var jsonData = JsonConvert.SerializeObject(msgBody);
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = httpClient.PostAsync(request.ToString(),content).Result;
if (!response.IsSuccessStatusCode)
throw new WebException(response.StatusCode.ToString() + ": " + response.ReasonPhrase);
uriString = response.Content.ReadAsStringAsync().Result;
return uriString;
}
有人請指出我在哪裏做錯了。我正在嘗試使用WPF。
uriString的值是什麼? –
https://outlook.office.com/api/v2.0/me/messages/{message_id}/replyall –
請檢查您是否正確傳遞{message_id}。你的錯誤表明你錯過了我認爲會來自你發佈的message_id的收件人。 –