首页 > 解决方案 > 如何修复 - 更新 plannertaskdetails - If-Match 标头包含无效值

问题描述

我正在尝试更新 (PATCH) 现有的 Microsoft Planner 任务,以向其中添加一 (1) 个清单项。我正在使用 Microsoft doc https://docs.microsoft.com/en-us/graph/api/plannertaskdetails-update?view=graph-rest-1.0&tabs=javascript作为参考,并且我正在使用 Postman 发送请求.

{
    "error": {
        "code": "",
        "message": "The If-Match header contains an invalid value.",
        "innerError": {
            "request-id": "7b50a25b-7c5a-443b-9a41-1b6314be4014",
            "date": "2019-05-16T23:59:03"
        }
    }
}

据我所知,If-Match 键的构建方式与 Microsoft 文章中使用它的方式完全相同。我发现了一篇类似的文章(https://powerusers.microsoft.com/t5/Connecting-To-Data/Custom-Connector-Graph-The-If-Match-header-must-be-specified-for/td- p/144092),但是这个人以不同的方式填写 If-Match 值,它对我根本不起作用......

我首先从创建任务后收到的响应中重用了 eTAG 值: "@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc=\""

有谁知道我在这里做错了什么?

这是我的补丁:

https://graph.microsoft.com/v1.0/planner/tasks/n...................pYAM-DX/details

这些是我的标题:

Content-Type: application/json

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub..........

If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="

这是我的身体:

{
    "previewType": "checklist",
    "checklist": {
    "{{$guid}}":{
      "@odata.type": "microsoft.graph.plannerChecklistItem",
      "title": "Update task details",
      "isChecked": false
        }   
    }
}

我期待 If-Match 键是正确的,因为我使用了 Microsoft 文章,但不知何故它会导致错误消息:

“If-Match 标头包含无效值。”

标签: postmanmicrosoft-graph-apimicrosoft-planner

解决方案


我有类似的问题。更新任务详细信息时,我使用了任务中的 etag。任务和任务详细信息是不同的对象。检查 - MS Graph doc

使用以下命令从创建任务的任务详细信息中获取 etag 值:

GET https://graph.microsoft.com/v1.0/planner/tasks/{task-id}/details

推荐阅读