3

Hi I am making post request to graph api(Beta) to create a task with assignee as follows.

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://graph.microsoft.com/beta/planner/tasks",
  "method": "POST",
  "headers": {
    "content-type": "application/json",
    "authorization": "Bearer token",
    "cache-control": "no-cache",
    "postman-token": "f6dd56ab-6fb4-f553-74aa-792945ba98b6"
  },
  "data":  {"title": "testTask","planId": "rPWMLzwXlUOA33dPNU9-dWUAAoRf,  "assignments": {"7d0544e0-2ed9-4aab-92a0-38efcaa292cd": {"orderHint": '5637'    } } }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

But it gives Error as follows,

{
  "error": {
    "code": "",
    "message": "The request is invalid.",
    "innerError": {
      "request-id": "14a2ef00-a271-4be8-8197-71aa46379017",
      "date": "2017-04-18T11:29:42"
    },
    "innererror": {
      "message": "task : An error has occurred.\r\n"
    }
  }
}

Task resource link: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/plannertask

0014
  • 893
  • 4
  • 13
  • 40
selvakumar
  • 1,771
  • 3
  • 20
  • 34

1 Answers1

1

I see two issues with the request.

  • For open type properties, you need to include the type of the complex type value of the property, in this case "microsoft.graph.plannerAssignment".
  • The order hints sent in the request follow the format described here, your input isn't valid according to that format. In this case, since this is the first item, the order hint should be " !". You can use " !" for all order hints to have one generated for you, if you don't care about the order of items.

After making necessary changes, your request should look like this:

{"title": "testTask","planId": "rPWMLzwXlUOA33dPNU9-dWUAAoRf, "assignments": {"7d0544e0-2ed9-4aab-92a0-38efcaa292cd": { "@odata.type": "microsoft.graph.plannerAssignment", "orderHint": " !"} } }
Tarkan Sevilmis
  • 1,443
  • 7
  • 9