简体   繁体   English

在SharePoint列表中发布项目给出了400错误的请求

[英]post an item in SharePoint list gives 400 Bad request

I have been 3 days trying to get items in text filed transfer into SharePoint list to work but now i have a 400 bad request error in the console. 我已经3天试图将文本文件中的项目转移到SharePoint列表中工作,但是现在控制台中出现400错误的请求错误。

This is my code: 这是我的代码:

    <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> 

I tried to input the data as hard coded but I didn't worked. 我试图以硬编码方式输入数据,但没有工作。 I don't know where is my problem ,also is x0020 right if SharePoint column have a space? 我不知道我的问题在哪里,如果SharePoint列有空格, x0020也正确吗?

The 400 bad request error may be caused if you/the user is part of too many Active Directory groups 如果您/用户属于太多Active Directory组,则可能导致400错误的请求错误

To resolve this there are two recommended solutions given by Microsoft. 要解决此问题,Microsoft提供了两种推荐的解决方案。 The first is to delete surplus Active Directory groups, the second is to configure registry settings and then restart your server. 第一个是删除多余的Active Directory组,第二个是配置注册表设置,然后重新启动服务器。

From source: 来自来源:

There are two options. 有两种选择。 Either remove extra AD groups from the user's AD account or configure the registry settings on IIS (Internet Information Server) web servers. 从用户的AD帐户中删除多余的AD组,或者在IIS(Internet信息服务器)Web服务器上配置注册表设置。

Registry location on IIS web servers: IIS Web服务器上的注册表位置:

HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\HTTP\\Parameters HKEY_LOCAL_MACHINE \\ System \\ CurrentControlSet \\ Services \\ HTTP \\ Parameters

Set values for MaxFieldLength and MaxRequestBytes registry keys. 设置MaxFieldLength和MaxRequestBytes注册表项的值。

Name Value-Type Value-Data 名称值类型值数据

MaxFieldLength DWORD 65534 MaxFieldLength DWORD 65534

MaxRequestBytes DWORD 16777216 MaxRequestBytes DWORD 16777216

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM