Sharepoint 2013 REST API not returning all items for a list

后端 未结 4 951
囚心锁ツ
囚心锁ツ 2021-02-13 19:38

The title states my problem quite exactly. If I try to gather all 400+ items from a list using sharepoint\'s REST API, I only get first 100.

I have read http://msdn.micro

4条回答
  •  情书的邮戳
    2021-02-13 20:20

    To anyone now seeing this, you can use data.d.__next to get the next 100 items. Using some good old recursion, you can get all the items like so

    function getItems(url) {
      $.ajax({
        url: url,
        type: "GET",
        headers: {
          "accept": "application/json;odata=verbose",
        },
        success: function(data) {
          console.log(data);
    
          // Do work
    
          if (data.d.__next) {
            getItems(data.d.__next);
          }
        },
        error: function(jqxhr) {
          alert(jqxhr.responseText);
        }
      });
    }

提交回复
热议问题