I am trying to insert 4000 items to the list , after inserting 1500 (around) following error occurred (forbidden 403).

enter image description here

 <script src="/Shared Documents/jquery-3.2.1.js"></script>
 <script src="/Shared Documents/xlsx.core.min.js"></script>
function AddItems()
var digest = "";
                url: "/_api/contextinfo",
                method: "POST",
                headers: {
                                "ACCEPT": "application/json;odata=verbose",
                                "content-type": "application/json;odata=verbose"
                success: function (data) {
                digest = data.d.GetContextWebInformation.FormDigestValue;
                error: function (data) {

}).done(function() {

    var fileInput = $("#uploadFile")[0].files;
    for (var i = 0; i < fileInput.length; i++) 
        var reader = new FileReader();
                var name = file.name;
                reader.onload = function (e) {
                var data = e.target.result;

                var result;
                var workbook = XLSX.read(data, { type: 'binary' });

                var sheet_name_list = workbook.SheetNames;
                sheet_name_list.forEach(function (y) { /* iterate through sheets */
                    //Convert the cell value to Json

                        var sheet= XLSX.utils.sheet_to_json(workbook.Sheets[y]);

                var siteUrl = _spPageContextInfo.webAbsoluteUrl;
                            url: siteUrl + "/_api/web/lists/GetByTitle('Emp')/items",
                            method: "POST",
                    async: false,
                            data: JSON.stringify({
                                    '__metadata': { 'type': 'SP.Data.EmpListItem' },
                                    'Title': row.Title,

                            headers: {
                                // "X-HTTP-Method":"MERGE",
                                "accept": "application/json;odata=verbose",
                            "content-type": "application/json;odata=verbose",
                                "X-RequestDigest": digest
                            success: function(data) {

                            error: function (err) {






                <input id="uploadFile" type="file" multiple="multiple">

<div style:"margin-top:10px">
                <input type="submit" onclick="AddItems()" value="Insert"> </input>

  • Are you running this against SharePoine Online or on-premise? – Thomas Gass Jul 25 '17 at 11:21
  • SharePoint online – ranjith Jul 28 '17 at 6:23
  • Might be a long shot but it could be the List Item View Threshold being hard-set at 5000 for SPO, though I doubt this would affect REST. Try inserting 3000 items when it already has 1500 (thus keeping it below 5000), if that works the threshold may be the problem. – Thomas Gass Jul 28 '17 at 13:24

For insert bulk items to SP List, you should consider about times out of your request. The default query request times out is 30000 milliseconds

You can use the approach below:

Sample GET request

http:// server/_api/search/query?querytext='sharepoint'&timeout=60000

Sample POST request




As you can see in the error message, it has to do with security validation of the page. Since you are doing a bulk update, I believe it takes considerable amount of time to finish the updates and thus in between itself the form digest for the page expires.

Please refer the below links -

Security Validation Issue - Stack Overflow

Explaination on page time out issue- MSDN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.