Microsoft Graph API:任务资源(plannerTask)的赋值(plannerAssignment)属性不是norking

时间:2017-04-18 11:54:17

标签: azure graph outlook microsoft-graph azure-ad-graph-api

您好我正在发布请求图表api(Beta)以创建与受让人的任务,如下所示。

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);
});

但是它给出了如下错误,

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

任务资源链接:https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/plannertask

1 个答案:

答案 0 :(得分:1)

我发现请求有两个问题。

  • 对于开放类型属性,您需要包含属性的复杂类型值的类型,在本例中为" microsoft.graph.plannerAssignment"。
  • 请求中发送的订单提示遵循here所述的格式,您的输入根据该格式无效。在这种情况下,由于这是第一项,因此订单提示应为" !&#34 ;.你可以使用" !"如果您不关心商品的顺序,那么为您生成一个订单提示。

进行必要的更改后,您的请求应如下所示:

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