【发布时间】:2019-04-06 22:33:30
【问题描述】:
我正在尝试创建全天活动:
let foobar: any = {
"subject": calendarEvent.Title+"v5",
"body": {
"contentType": "HTML",
"content": calendarEvent! || !calendarEvent.Description ? "No Description": calendarEvent.Description,
},
"start": {
"dateTime": calendarEvent.EventDate,
"timeZone": moment.tz.guess(),
},
"end": {
"dateTime": calendarEvent.EndDate,
"timeZone": moment.tz.guess(),
},
"location": {
"displayName": !calendarEvent || !calendarEvent.Location ? "No Location": calendarEvent.Location,
},
"isAllDay": !calendarEvent || !calendarEvent.fAllDayEvent ? false : true,
};
context.msGraphClientFactory.getClient()
.then((client: MSGraphClient) => {
client.api("/me/calendar/events").post(foobar)
.then((content: any) => {
console.log("CalendarService | createCalendarEvent | content: ", content);
});
});
日志:
当我包含“isAllDay”属性时,它会失败并返回 400(错误请求)。
我排除了该属性,它正在创建没有问题的事件。
有什么建议吗?
编辑:忘了说,如果我将isAllDay 传递为false,则创建事件。
EDIT2:这是通过来自 SPFx 项目的 MSGraphClient 进行连接。
【问题讨论】:
-
您访问的是什么 API?
-
@cmaynard MSGraph
-
会不会是你的开始和结束时间不是午夜:eliostruyf.com/…
-
@cmaynard,谢谢。
标签: typescript microsoft-graph-api spfx