ErrorInvalidRequest while using post request in office365

坚强是说给别人听的谎言 提交于 2019-12-25 04:50:09

问题


using restClient, I am trying to add a new event.

url: https://outlook.office365.com/ews/odata/Me/Events

My json for the creation of an event is

{"IsAllDay":false,"Subject":"TEST","Start":"2015-02-20T07:32:39Z","End":"2015-02-20T08:32:39Z","Body":{"ContentType":"HTML","Content":"TEST JRA ? TU VOIS ?"}}

The response I get is

{
   "error":
   {
       "code": "ErrorInvalidRequest",
       "message": "Cannot read the request body."
   }
}

What is wrong with my json and how do I solve this error ?


回答1:


Make sure your Content-Type is "application/json".




回答2:


I am able to make the request work. See below for sample request and response.

POST https://outlook.office365.com/api/v1.0/Me/Events HTTP/1.1
Authorization: <Snipped>
Content-Type: Application/Json

{
   "IsAllDay":false,
   "Subject":"TEST",
   "Start":"2015-02-20T07:32:39Z",
   "End":"2015-02-20T08:32:39Z",
   "Body":{
      "ContentType":"HTML",
      "Content":"TEST JRA ? TU VOIS ?"
    }
}


来源:https://stackoverflow.com/questions/28623878/errorinvalidrequest-while-using-post-request-in-office365

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!