我想在发布消息时创建一个附件。我按照下面的文档并测试了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 请求。”
代码有问题吗?
最佳答案
“不支持 OData 请求”错误消息是由错误引起的。该问题的修复程序正在推出,应该会在大约一个月内广泛使用。我们还在发行说明中添加了一条注释。
另请注意,代码中的 @odata.type 应为“microsoft.graph.fileAttachment”。 “Microsoft.OutlookServices”命名空间只能与 Outlook API/端点一起使用,而不能与 MS Graph API/端点一起使用。
关于javascript - Microsoft Graph API,创建附件不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34129356/