Office365 REST API - 创建带有附件的日历事件
Office365 REST API - Creating a calendar event with attachments
我无法使用 Office365 的 Rest 创建带有附件的日历事件 API。创建没有附件的事件不是问题。尝试创建带有附件的事件会创建事件,但不会添加我发送的文件。服务器以 201 响应代码响应。
我正在发送 POST 请求至:
https://graph.microsoft.com/v1.0/me/calendars/$(calendarID)/events
我使用以下授权header:
Authorization: Bearer $(tokenString)
请求负载:
{
"start": {
"dateTime": "2017-09-27T20:00:00.000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-09-27T21:00:00.000",
"timeZone": "UTC"
},
"attendees": [
{
"emailAddress": {
"address": "person@example.com"
},
"type": "Required"
}
],
"subject": "Example subject",
"body": {
"content": "Example content",
"contentType": "Text"
},
"hasAttachments": true,
"sensitivity": "Normal",
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "$(fileName)",
"contentBytes": "$(base64EncodedString)"
}
]
}
我正在关注 https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/calendar_post_events. My event follows the event schema, and the attachments follow the fileAttachment schema 上的文档。
我已经为@odata.type 尝试了不同的值,从请求中删除了 hasAttachments,并向附件添加了名称、大小和内容类型字段。所有这些都给出相同的结果 - 201 响应,以及创建的没有附件的事件。
非常感谢任何帮助,谢谢!
我也看到了!我可以 post 事件创建后的附件,只是不包括初始创建负载。
因此,作为解决方法,您可以创建事件,然后执行
POST /me/events/{eventid}/attachments
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "$(fileName)",
"contentBytes": "$(base64EncodedString)"
}
我会与日历人员核实一下,看看为什么它在最初的 POST 期间不起作用。
我无法使用 Office365 的 Rest 创建带有附件的日历事件 API。创建没有附件的事件不是问题。尝试创建带有附件的事件会创建事件,但不会添加我发送的文件。服务器以 201 响应代码响应。
我正在发送 POST 请求至:
https://graph.microsoft.com/v1.0/me/calendars/$(calendarID)/events
我使用以下授权header:
Authorization: Bearer $(tokenString)
请求负载:
{
"start": {
"dateTime": "2017-09-27T20:00:00.000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2017-09-27T21:00:00.000",
"timeZone": "UTC"
},
"attendees": [
{
"emailAddress": {
"address": "person@example.com"
},
"type": "Required"
}
],
"subject": "Example subject",
"body": {
"content": "Example content",
"contentType": "Text"
},
"hasAttachments": true,
"sensitivity": "Normal",
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "$(fileName)",
"contentBytes": "$(base64EncodedString)"
}
]
}
我正在关注 https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/calendar_post_events. My event follows the event schema, and the attachments follow the fileAttachment schema 上的文档。
我已经为@odata.type 尝试了不同的值,从请求中删除了 hasAttachments,并向附件添加了名称、大小和内容类型字段。所有这些都给出相同的结果 - 201 响应,以及创建的没有附件的事件。
非常感谢任何帮助,谢谢!
我也看到了!我可以 post 事件创建后的附件,只是不包括初始创建负载。
因此,作为解决方法,您可以创建事件,然后执行
POST /me/events/{eventid}/attachments
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "$(fileName)",
"contentBytes": "$(base64EncodedString)"
}
我会与日历人员核实一下,看看为什么它在最初的 POST 期间不起作用。