0
我想在發佈消息時創建附件。我按照下面的文檔並測試api,但它不起作用!Microsoft Graph API,創建附件不起作用?
http://graph.microsoft.io/docs/api-reference/v1.0/api/post_post_attachments
我的JavaScript代碼如下:
obj.createAttachment = function (groupId, threadId, postId) {
var d = $q.defer();
var s = Base64.encode("one drive");
HttpClient.post({
url: "https://graph.microsoft.com/v1.0/groups/" + groupId + "/threads/" + threadId + "/posts/" + postId + "/attachments",
data: {
"@odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "test_one_drive.txt",
"ContentType": "text/plain",
"IsInline": true,
"ContentLocation": "https://wiadvancetechology.sharepoint.com/sites/wiogroup85/Shared%20Documents/test%20one%20drive.txt",
"ContentBytes": s
}
}).then(function (response) {
d.resolve(response);
});
return d.promise;
};
但反應總是顯示 「405(不允許的方法)」。 錯誤消息是「不支持OData請求。」
代碼有問題嗎?
如果您查看文檔,所有屬性都使用駱駝套管,而在您的示例中,您使用的是Pascal套管。你可以嘗試改變套管的屬性,以駱駝套管,看看是否有幫助? –
我將套管更換爲駱駝套管,但仍無法使用。更改類似於「名稱」,「contentType」,「isInline」,「contentLocation」,「contentBytes」 –
響應錯誤消息是「OData請求不受支持」。 –