Search code examples
postmanmicrosoft-graph-apimicrosoft-planner

How to fix - Update plannertaskdetails - If-Match header contains an invalid value


I am trying to update (PATCH) an existing Microsoft Planner task, to add one (1) checklist item to it. I am using Microsoft doc https://learn.microsoft.com/en-us/graph/api/plannertaskdetails-update?view=graph-rest-1.0&tabs=javascript as a reference, and I am using Postman to send the request.

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

As far as I can see, the If-Match key is built up exactly the same as how Microsoft's article used it. I have found a somewhat similar article (https://powerusers.microsoft.com/t5/Connecting-To-Data/Custom-Connector-Graph-The-If-Match-header-must-be-specified-for/td-p/144092), but this person is filling in the If-Match value differently, and it doesn't work for me at all...

I reused the eTAG value from the response received after creating the task in the first place: "@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc=\""

Does anyone have a clue what I am doing wrong here?

This is my PATCH:

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

These are my headers:

Content-Type: application/json

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

If-Match: W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="

This is my body:

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

I was expecting the If-Match key to be correct, as I have used the Microsoft article, but somehow it results in the error message:

"The If-Match header contains an invalid value."


Solution

  • I had similar problem. I used etag from task when updates Task details. The Task and Task Details are different objects. Check on - MS Graph doc

    Get etag value from Task details of created task using:

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