首页 > 解决方案 > 如何修复 ""code":"RequestBodyRead"" 错误?

问题描述

我正在尝试制作一个使用 Microsoft API 转发电子邮件的 Outlook 加载项,但我收到一条错误消息,指出根据文档,“评论”不是有效参数。我正在关注转发文档: 这里

var forwardMessage = Office.context.mailbox.restUrl +
  '/beta/me/messages/' + itemId + '/forward';
var body= JSON.stringify({
      "comment": item,
      "toRecipients": [
        {
          "emailAddress": {
            "address": "email@email.com",
            "name": "name"
          }
        }
      ]
    })
    $.ajax({
      url: forwardMessage,
      method:"POST",
      dataType: 'json',
    headers: { 'Authorization': 'Bearer ' + accessToken,
  'Content-Type': "application/json" },
  data: body
    }).then(
      console.log("done")
    )
  }).catch(function(error){
    throw error;
  });

错误:

{"error":{"code":"RequestBodyRead","message":"The parameter 'comment' in the request payload is not a valid parameter for the operation 'Forward'."}}

标签: javascriptajaxmicrosoft-graph-apioutlook-addinoutlook-web-addins

解决方案


推荐阅读