【发布时间】:2018-03-14 21:08:52
【问题描述】:
我正在尝试基于通信网站模板创建一个共享点在线网站集,如 Microsoft 在此处 https://docs.microsoft.com/en-us/sharepoint/dev/apis/communication-site-creation-rest 中所述,通过在不同共享点网站的页面上使用 javascript
但是,我不断收到 403 的响应——尽管我是租户管理员,因此绝对有权创建站点。 我正在从诸如 companyname.sharepoint.com/sites/myTestSite/sitepages/RunSomeJS.aspx 之类的 url 的页面运行下面的脚本
我已尝试指定两者的 REST 端点域 公司名称.sharepoint.com 和 公司名称-admin.sharepoint.com 但得到同样的错误。
function DoRestCall(){
var body={'parameters':
{
"__metadata":{"type":"SP.Publishing.CommunicationSiteCreationRequest"},
"AllowFileSharingForGuestUsers":false,
"Classification":"MyTest Communication Site",
"Description":"Here is my communication site",
"SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
"Title":"MyTest Communication Site",
"Url":"https://companyname.sharepoint.com/sites/testSiteName",
"lcid":1033
}
};
$.ajax({
type: 'POST',
url: "https://companyname.sharepoint.com/_api/sitepages/create",
contentType: 'application/json',
processData: false,
headers:{
"accept":"application/json;odata=verbose",
"content-type":"application/json;odata=verbose",
"X-RequestDigest": document.getElementById("__REQUESTDIGEST").value
},
data: JSON.stringify(body),
success: function ()
{
alert('CREATION REQUEST SUBMITTED');
},
error: function(data){
alert('failure:' + data.statusText );
}
});
}
关于我在这里做错了什么有什么建议吗?
【问题讨论】:
标签: javascript rest sharepoint sharepoint-online