GetListItems Webservice ignores my request filter

The code below apparently executes the web service and returns values, but ignores the where clause (thus returning all the items in the list). This is the simplest form of problem that I have encountered.

The TestQuery list is a simple user list with no user-defined fields. Can anyone understand why the filter is not working?

<body>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
    soapEnv += "<listName>TestQuery</listName>";
    soapEnv += "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>One</Value></Eq></Where></Query>";
    soapEnv += "<ViewFields><ViewFields><FieldRef Name='Title'/></ViewFields></ViewFields><RowLimit>1</RowLimit>";
    soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

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

function processResult(xData, status) {
            $('#WSResponse').text(status);
    $(xData.responseXML).find("z\\:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
    });
    //}
}
</script>


<ul id="tasksUL"/>
<div id="WSResponse"/>

</body>
+3
source share
3 answers

You are missing the <query>. The formatting of these parameters is somewhat inconsistent.

There is a blog post with a working example:

http://tqcblog.com/2007/09/24/sharepoint-blog-content-rating-with-javascript-and-web-services

+3

, Query ViewField viewField, - :

var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"; 
    soapEnv += "<listName>TestQuery</listName>"; 
    soapEnv += "<query><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>One</Value></Eq></Where></Query></query>"; 
    soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/></ViewFields></viewFields><RowLimit>1</RowLimit>"; 
    soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>"; 
+4

I also ran into the same problem .. "The Temple solution solved the request problem ... but to make RowLimit work, I made the" R "lower case ie,

<rowLimit> not <RowLimit>

It took me a lot of time ... :) Happy coding ...

+2
source

Source: https://habr.com/ru/post/1707872/


All Articles