【发布时间】:2018-05-25 07:19:59
【问题描述】:
是否有人知道如何使用 Sharepoint REST _api 将事件发布到 SharePoint Online 日历列表。
我在堆栈上找到了这篇文章:link 但它使用了我不必在我的情况下使用的授权,因为我的应用程序位于 sharepoint 内部。我找到了有关如何将 CRUD 制作为 Outlook 日历的文档。但它当然不包括共享点。
这是目前为止的代码:
function PostToBokningar() {
var url = `${_spPageContextInfo.webAbsoluteUrl}/_api/web/lists/getbytitle('Bokningar')/items`;
//requestHeaders
var requestHeaders = {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": jQuery('#__REQUESTDIGEST').val()
}
//Data
var data = {
__metadata: { "type": "SP.Data.BokningarListItem" },
Title: "Test title",
EventDate: moment.utc("2017-12-12 10:00").format('YYYY-MM-DD HH:mm:ssZ'),
EndTime: moment.utc("2017-12-12 17:00").format('YYYY-MM-DD HH:mm:ssZ'),
Description: "test description"
};
//requestBod
var requestBody = JSON.stringify(data);
//Post
var post = jQuery.ajax({
url: url,
type: "POST",
headers: requestHeaders,
data: data
})
}
我得到的错误信息是:
{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Invalid JSON. A token was not recognized in the JSON content."}}}
有什么建议吗?
【问题讨论】:
标签: javascript sharepoint-online sharepoint-list sharepoint-api