规划器 - 更新任务详细信息时的BadRequest

时间:2016-06-24 11:03:38

标签: microsoft-graph

使用Graph API时,我可以成功创建任务,然后我希望更新任务详细信息,特别是描述并添加一些参考。

我按照此处的文档https://graph.microsoft.io/en-us/docs/api-reference/beta/api/taskdetails_update

进行操作

我在创建任务时使用eTag添加请求标头,Authentication Bearer,If-Match。网址是:

https://graph.microsoft.com/beta/tasks/6oqAlz30WE66F915zUcSepYAM2ki/details

使用的Http方法是PATCH 身体是:

{
  "description": "My Task Title description",
  "references": {
    "https://tenant.sharepoint.com/teams/teamsite/_layouts/15/WopiFrame.aspx?sourcedoc={521F1D0F-397D-4163-BB16-7C9EF436650B}&file=Release Notes.one&action=view&DefaultItemOpen=1": {
      "alias": "OneNote",
      "type": "OneNote"
    }
  }
}

Http响应是:

StatusCode:400,ReasonPhrase:'错误请求'

响应内容是:

{
    "error": {
        "code": "",
        "message": "The request is invalid.",
        "innerError": {
            "request-id": "4e2eae7d-9587-4a69-8c9d-40c5d571190a",
            "date": "2016-06-24T10:57:33"
        }
    }
}

关于我在这里做错了什么的想法?

使用HttpClient,HttpRequestMessage在C#.Net中编码。

1 个答案:

答案 0 :(得分:2)

引用对象中的URL需要进行编码,就是这样。即。

{
  "description": "My Task Title description",
  "references": {
    "https%3A%2F%2Ftenant.sharepoint.com%2Fteams%2Fteamsite%2F_layouts%2F15%2FWopiFrame.aspx%3Fsourcedoc%3D%7B521F1D0F-397D-4163-BB16-7C9EF436650B%7D%26file%3DRelease+Notes.one%26action%3Dview%26DefaultItemOpen%3D1": {
      "alias": "OneNote",
      "type": "OneNote"
    }
  }
}