2017-04-18 67 views
2

您好我正在發出請求以圖形API(Beta)創建與受讓人的任務如下。Microsoft Graph API:任務資源(plannerTask)的任務(plannerAssignment)屬性不是norking

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

我看到與請求的兩個問題。

  • 對於打開類型屬性,您需要包含屬性的複雜類型值的類型,在本例中爲「microsoft.graph.plannerAssignment」。
  • 請求中發送的訂單提示遵循here所述的格式,根據該格式您的輸入無效。在這種情況下,由於這是第一項,所以訂單提示應該是「!」。您可以使用 」 !」如果你不關心項目的順序,所有的訂單提示都可以爲你生成。

進行必要的修改後,你的要求應該是這樣的:

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