2015-12-07 21 views
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請求。」

代碼有問題嗎?

+0

如果您查看文檔,所有屬性都使用駱駝套管,而在您的示例中,您使用的是Pascal套管。你可以嘗試改變套管的屬性,以駱駝套管,看看是否有幫助? –

+0

我將套管更換爲駱駝套管,但仍無法使用。更改類似於「名稱」,「contentType」,「isInline」,「contentLocation」,「contentBytes」 –

+0

響應錯誤消息是「OData請求不受支持」。 –

回答

1

「The OData request is not supported」錯誤消息是由錯誤引起的。它的一個解決方案正在推出,並應在大約一個月內廣泛提供。我們還在發行說明中添加了一條註釋。

請注意,代碼中的@ odata.type應該是「microsoft.graph.fileAttachment」。 「Microsoft.OutlookServices」命名空間只能與Outlook API /端點一起使用,而不能用於MS Graph API /端點。

相關問題