Reputation: 21
I would like to create an attachment when I'm going to post a message. I followed the document as below and testing the api, but it doesn't works!!
http://graph.microsoft.io/docs/api-reference/v1.0/api/post_post_attachments
My JavaScript code is as below:
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;
};
But the response always show "405 (Method Not Allowed)". The error message is "The OData request is not supported."
Is there something wrong in the code?
Upvotes: 0
Views: 1503
Reputation: 1694
The "The OData request is not supported" error message is caused by a bug. A fix for it is being rolled out and should be widely available in about a month. We're also adding a note to the release notes.
Please also note that the @odata.type in your code should be "microsoft.graph.fileAttachment". The "Microsoft.OutlookServices" namespace should only be used with the Outlook API/endpoint and not the MS Graph API/endpoint.
Upvotes: 1