我正在尝试使用graph-js-sdk-web.js我相信我完全按照说明将文本文件附加到 Outlook 中的现有事件,但我得到了422响应。我如何让它附加文件?
我很确定我eventID是正确的,因为我可以创建一个事件并通过该 ID 获取它。我很确定我的文件的后加载是正确的,因为我自己附加了文件,然后通过扩展附件的 id 获取了该事件,并且它是相同的 OData 类型、名称和内容。
到目前为止,我在 google 上搜索了响应,我所看到的一切要么只对人们有效,要么与该示例相比,他们对代码不感兴趣。
这是我请求的权限
openid profile User.Read MailboxSettings.Read Calendars.ReadWrite
Run Code Online (Sandbox Code Playgroud)
这匹配授予注册应用程序的权限。
这是客户端和文件附件代码:
// Create a Graph client
var client = MicrosoftGraph.Client.init({
authProvider: (done) => {
// Just return the token
done(null, sessionStorage.accessToken);
}
});
client
.api('/me/calendar/events/' + eventID + '/attachments')
.post({
attachment: {
"@odata.type": "#microsoft.graph.fileAttachment",
name: "helloworld.txt",
contentBytes: "SGVsbG8gd29ybGQh"
}
}, (error, response) => {
if (error)
console.log(error);
else {
console.log(response); …Run Code Online (Sandbox Code Playgroud)