Sharepoint Api-在列表中创建新项目 [英] Sharepoint Api -create new item in the list
本文介绍了Sharepoint Api-在列表中创建新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi ,
我正在尝试通过邮递员中的方法(Post)在SharePoint 2013列表中创建新项目:
I am trying to create new item in SharePoint 2013 list by the method(Post), in Postman:
<网站地址>/_ api/lists/getbytitle('< Listname>')/items/
<Site address>/_api/lists/getbytitle('<Listname>')/items/
但是我被禁止出现错误403,
But I getting error 403 forbidden,
我已签入SharePoint列表,并且拥有完全控制权,
I have check in the SharePoint list and I have full control,
希望获得您的建议:)
推荐答案
由于表单摘要,您很可能会收到此错误.
Most likely you are getting this error because of form digest.
您是否尝试过以下方法:
Have you tried below approach:
function getFormDigest(webUrl) {
return
ajax url webUrl 方法 标头 } createListItem webUrl listName itemProperties getFormDigest webUrl 然后 功能 ( ) {
.ajax({ url: webUrl + "/_api/contextinfo", method: "POST", headers: { "Accept": "application/json; odata=verbose" } }); } function createListItem(webUrl, listName, itemProperties) { return getFormDigest(webUrl).then(function (data) { return
ajax url webUrl listName '"/items" 类型 processData , , JSON stringify itemProperties 标头 "application/json; odata = verbose" 数据 d GetContextWebInformation FormDigestValue
.ajax({ url: webUrl + "/_api/web/lists/getbytitle('" + listName + "')/items", type: "POST", processData: false, contentType: "application/json;odata=verbose", data: JSON.stringify(itemProperties), headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest": data.d.GetContextWebInformation.FormDigestValue } }); }); }
这篇关于Sharepoint Api-在列表中创建新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文