在office365中使用post请求时ErrorInvalidRequest

时间:2015-02-20 07:44:20

标签: api rest office365 rest-client

使用restClient,我正在尝试添加一个新事件。

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

我创建活动的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 ?"}}

我得到的回应是

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

我的json有什么问题,如何解决这个错误?

2 个答案:

答案 0 :(得分:1)

确保您的内容类型为"application/json"

答案 1 :(得分:0)

我能够使请求有效。请参阅下面的样品申请和回复。

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 ?"
    }
}