我已经3天试图将文本文件中的项目转移到SharePoint列表中工作,但是现在控制台中出现400错误的请求错误。
这是我的代码:
<script type="text/javascript">
function createListItem() {
//Fetch the values from the input elements
var eName = $('#title').val();
var eDesg = $('#name').val();
var eEmail = $('#email').val();
var eMobile = $('#moblie').val();
var eResidency = $('#Residency').val();
var eRequestDetails = $('#RequestDetails').val();
var eStatus = $('#Status').val();
//alert(fullName);
//alert(_spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ExitPermitRequest')/items");
$.ajax({
async: false,
url: "http://stag.psa.gov.qa/en/_api/web/lists/GetByTitle('ndsList')/items",
method: "POST",
data: JSON.stringify({
'__metadata': {
'type': 'SP.Data.ndsListListItem' // it defines the ListEnitityTypeName
},
'Title': eName,
'Full_x0020_Name': eDesg,
'Moblile_x0020_Phone': eMobile,
'E-Mail': eEmail,
'Residency': Residency,
'RequestDetails': eRequestDetails,
'Status': eStatus
}),
headers: {
"accept": "application/json;odata=verbose", //It defines the Data format
"content-type": "application/json;odata=verbose", //It defines the content type as JSON
"X-RequestDigest": $("#__REQUESTDIGEST").val() //It gets the digest value
},
success: function (data) {
alert("Item created successfully", "success"); // Used sweet alert for success message
},
error: function (error) {
alert("error occured"+ error);
}
})
}
</script>
<div id="insert1">
<table>
<tr>
<td> Title: </td>
<td>
<input type="text" id="title" placeholder="Title" /> </td>
</tr>
<tr>
<td> Full Name: </td>
<td>
<input type="text" id="name" placeholder="Full Name" /> </td>
</tr>
<tr>
<td> Email: </td>
<td>
<input type="text" id="email" placeholder="Email" /> </td>
</tr>
<tr>
<td> Moblie Number: </td>
<td>
<input type="text" id="moblie" placeholder="Moblie Number" /> </td>
</tr>
<tr>
<td> Residency: </td>
<td><select id="Residency">
<option selected>In Qatar</option>
<option>Outside Qatar</option>
</select></td>
</tr>
<tr>
<td> RequestDetails: </td>
<td>
<input type="text" id="RequestDetails" placeholder="RequestDetails" /> </td>
</tr>
<tr>
<td> Status: </td>
<td><select id="Status">
<option selected>Not Started</option>
<option>In Progress</option>
<option>Pending</option>
<option>Completed</option>
</select></td>
</tr>
<tr>
<td></td>
<td>
<button onclick="createListItem()">Click me</button>
</td>
</tr>
</table>
</div>
我试图以硬编码方式输入数据,但是我没有工作。 我不知道我的问题在哪里,如果SharePoint列中有空格, x0020 也正确吗?
答案 0 :(得分:0)
如果您/用户属于太多Active Directory组,则可能导致400错误的请求错误
要解决此问题,Microsoft提供了两种推荐的解决方案。第一个是删除多余的Active Directory组,第二个是配置注册表设置,然后重新启动服务器。
来自source:
有两个选项。从用户的帐户中删除多余的广告组 AD帐户或在IIS(Internet 信息服务器)Web服务器。
IIS Web服务器上的注册表位置:
HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Services \ HTTP \ Parameters
设置MaxFieldLength和MaxRequestBytes注册表项的值。
名称值类型值数据
MaxFieldLength DWORD 65534
MaxRequestBytes DWORD 16777216