none
GetListItems with jQuery - Using ListItemCollectionPositionNext as a Query Option

    Question

  • Hi,

    I've been trying many different options but I can't seem to get the paging working for a CAML query. I've tried several different methods and found little documentation on the subject other than the MSDN link below. I keep getting a 400 error "Bad Request" every time I try the CAML query with the ListItemCollectionPositionNext query option. My code is below. I would appreciate any advice you can give.

    http://msdn.microsoft.com/en-us/library/dd586530(office.11).aspx

    var soapEnv =
                "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
                    "<soapenv:Body>" +
                         "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                            "<listName>TestList</listName>" +
                            "<QueryOptions><Paging ListItemCollectionPositionNext='Paged=TRUE&p_ID=30' /></QueryOptions>" +
                            "<query><Query /></query>" +
                        "</GetListItems>" +
                    "</soapenv:Body>" +
                "</soapenv:Envelope>";

            $.ajax({
                url: "http://[mysite]/sites/sg/_vti_bin/lists.asmx",
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult,
                contentType: "text/xml; charset=\"utf-8\""
            });


    Thanks,

    Max


    • Edited by MwMorrow Thursday, May 24, 2012 9:35 PM
    Thursday, May 24, 2012 9:23 PM

Answers

  • Try MwMorrow

    According to what I have read from similar causes, you need to surround the <QueryOptions> tag with an additional <queryOptions> (lower case 'q') like this: 

      "<queryOptions><QueryOptions><Paging ListItemCollectionPositionNext='Paged=TRUE&p_ID=30' /></QueryOptions></queryOptions>" +


    Regards Bjoern
    Blog

    • Marked as answer by MwMorrow Friday, May 25, 2012 12:02 PM
    Thursday, May 24, 2012 9:55 PM
    Moderator

All replies

  • Try MwMorrow

    According to what I have read from similar causes, you need to surround the <QueryOptions> tag with an additional <queryOptions> (lower case 'q') like this: 

      "<queryOptions><QueryOptions><Paging ListItemCollectionPositionNext='Paged=TRUE&p_ID=30' /></QueryOptions></queryOptions>" +


    Regards Bjoern
    Blog

    • Marked as answer by MwMorrow Friday, May 25, 2012 12:02 PM
    Thursday, May 24, 2012 9:55 PM
    Moderator
  • Hi,

    Please try the option below 

     "<query><Query /></query>" + -> " <Query><Range><StartAt>101</StartAt><Count>10</Count></Range></Query>"

    Change the start at and count number as you want to get result.Also I may be asking a stupid question but a <Query/> inside a <query> tag, what purpose does it serve.

    Friday, May 25, 2012 10:46 AM
  • Thanks Bjoern,

    This was actually the problem. Also, I needed to replace the & with &amp; to get it to work properly.

    Friday, May 25, 2012 12:02 PM