Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api mail.send不接受HTML/CSS代码_Api_Outlook_Microsoft Graph Api_Blueprism_Microsoft Graph Mail - Fatal编程技术网

Api mail.send不接受HTML/CSS代码

Api mail.send不接受HTML/CSS代码,api,outlook,microsoft-graph-api,blueprism,microsoft-graph-mail,Api,Outlook,Microsoft Graph Api,Blueprism,Microsoft Graph Mail,我从收到的电子邮件中复制了(HTML)源代码,只是为了获得该电子邮件的模板/格式,这是我在运行API时收到的错误消息: Internal : Unexpected error Error during Web API HTTP Request HTTP Status Code: 400 HTTP Response Content: { "error": { "code": "BadRequest", "me

我从收到的电子邮件中复制了(HTML)源代码,只是为了获得该电子邮件的模板/格式,这是我在运行API时收到的错误消息:

Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {
  "error": {
    "code": "BadRequest",
    "message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
    "innerError": {
      "date": "2020-12-02T17:01:05",
      "request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d",
      "client-request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d"
    }
  }
}
我已经测试了使用HTML的基本命令,例如使文本加粗和换行,但如果更复杂,我将收到一个错误

更新** 谢谢你们的回复,伙计们,我使用的电话是这样的:

{
  "message": {
    "subject": "[Subject]",
    "body": {
      "contentType": "HTML",
      "content": "[Email Body Content]"
    },
    "toRecipients": [
      {
        "emailAddress": {
          "address": "[Email Address]"
        }
      }
    ],
    "internetMessageHeaders":[
      {
        "name":"x-custom-header-group-name",
        "value":"Nevada"
      },
      {
        "name":"x-custom-header-group-id",
        "value":"NV001"
      }
    ]
  }
}
**将内容类型更改为text/html时,收到另一个更新**。此错误:

Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 415
HTTP Response Content: {"error":{"code":"RequestBodyRead","message":"A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'Microsoft.OData.ODataMediaType, Microsoft.OData.ODataMediaTyp...' matches the content type 'text/plain; charset=utf-8'."}}
注:我也尝试将text/plain作为内容类型


谢谢

好的,我尝试了上面的有效负载(刚刚更新了电子邮件地址)并用Microsoft Graph Explorer进行了测试。它对我有用:)

这是有效载荷:

{"message":{"subject":"[Subject]","body":{"contentType":"HTML","content":"[Email Body Content]"},"toRecipients":[{"emailAddress":{"address":"test@domain.onmicrosoft.com"}}],"internetMessageHeaders":[{"name":"x-custom-header-group-name","value":"Nevada"},{"name":"x-custom-header-group-id","value":"NV001"}]}}
以下是快照:

(1)共享您正在使用的API调用(2)您是否也可以使用POSTMAN/Graph Explorer重新编写问题?您是否有一些代码可以共享以复制错误?谢谢您的回答,我已编辑了帖子以显示调用。我在《邮递员》中转载了同样的结果。我确信这与内容类型有关,但我无法计算出来。谢谢,让我来看看。谢谢你的回复。如果你把源代码从一封包含图片和css的邮件中复制到邮件正文中,这行得通吗?谢谢,我还没有在邮件正文中测试过带有图像/css的电子邮件,但它应该可以工作。如果你遇到任何问题,就在这里报告。如果它有效,请考虑上面的答案——这样对社区的其他人也是有用的;