none
SP 2013 REST API "Skip" Function Not Working RRS feed

  • Question

  • Hello Community,

    I'm using SP 2013 enterprise, I've created a list with a number field that's called WPO (Web Part Order).  I want to query that list and return the items that have a WPO greater than 7.  I've written the script below, and through several tests I have determined that everything is working except the "Skip" function, which never skips over the first 7 items.  Has anyone else seen this issue and if so please provide guidance and code needed to resolve it.

    //Helpful Links Right
    $(function () {
        $.ajax({
            url: "/sites/bobhome/_api/web/lists/GetByTitle('Links List')/items?$Filter=Category eq 'Helpful Links'&$Select=URL,WPO&$orderby=WPO asc&$linecount=allpages&$skip=7&$top=7",
            type: "GET",
            headers: {
                "accept": "application/json;odata=verbose"
            },
        }).success(function (data) {
    
            //alert("WPO " + WPO);        
            var listItemInfo = '';
    
            $.each(data.d.results, function (key, value) {
                listItemInfo += "<li><a href='" + value.URL.Url + "'>" + value.URL.Description + " " + value.WPO + "</a></li>";
            });
    
            $("#HLRLinksList").html(listItemInfo);
        });
    });
    

    Thanks!

    Tom


    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award - Linked-In - SharePoint Gypsy

    Monday, July 27, 2015 8:33 PM

Answers

  • Hi Tom,

    Currently, $skip query option is not supported in SharePoint 2013/Online REST interface, you can use $skiptoken instead.

    Here is a working demo for your reference:

    function getPagedItems()
    {
    	//start from the 5th records
    	var SKIPTOKEN = 4;
    
    	//get 5 records back
    	var TOP = 5;
    
    	$.ajax({
    		url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('List1')/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d"+SKIPTOKEN+"&%24top="+TOP,
    		method: "GET",
    		headers: { "Accept": "application/json; odata=verbose" },
    		success: function (data) {
    		  console.log(data);
    		}
    	}); 
    }
    

    Thanks 

    Patrick Liang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Marked as answer by Tom Molskow Tuesday, July 28, 2015 3:28 PM
    Tuesday, July 28, 2015 8:34 AM
    Moderator

All replies

  • Hi Tom,

    Currently, $skip query option is not supported in SharePoint 2013/Online REST interface, you can use $skiptoken instead.

    Here is a working demo for your reference:

    function getPagedItems()
    {
    	//start from the 5th records
    	var SKIPTOKEN = 4;
    
    	//get 5 records back
    	var TOP = 5;
    
    	$.ajax({
    		url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('List1')/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d"+SKIPTOKEN+"&%24top="+TOP,
    		method: "GET",
    		headers: { "Accept": "application/json; odata=verbose" },
    		success: function (data) {
    		  console.log(data);
    		}
    	}); 
    }
    

    Thanks 

    Patrick Liang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Marked as answer by Tom Molskow Tuesday, July 28, 2015 3:28 PM
    Tuesday, July 28, 2015 8:34 AM
    Moderator
  • Hello Community,

    BTW, I found another way to do this by using a compound filter.  I guess this is much less well known because I tried several methods from several blogs before I hit on the right way to do this.  So, for everyone's benefit, here is the REST API query code:

    url: "/sites/companysite/_api/web/lists/GetByTitle('Links List')/items?$Filter=Var1 gt 7 and Var2 eq 'Helpful Links'&$select=Var1,Var2,Var3"

    Thanks!

    Tom


    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award - Linked-In - SharePoint Gypsy

    Tuesday, July 28, 2015 6:10 PM
  • Hi Patrick,

    SkipToken is not working properly. try to delete item(s) from the list so that the items ID's won't be in perfect sequence

    e.g, 1 3 6 7 11 ... this way p_ID inputs will return invalid output some items will appear twice on two different pages

    • Proposed as answer by M.Hijazi Sunday, August 6, 2017 9:46 AM
    Sunday, August 6, 2017 9:46 AM