Failure to access Spservices in a Sharepoint list

Asked

Viewed 117 times

2

I created a Spservices that queries a list in Sharepoint 2010 and returns the value of a single field. However, this query is returning the following error:

soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.Não existe nenhuma Web chamada "/blog/Lists/Postagens/_vti_bin/Lists.asmx".

My code is this:

var queryText = "<Query>"+
                    "<Where>"+
                        "<Eq>"+
                            "<FieldRef Name='ID'/>"+
                                "<Value Type='Number'>" + IDPost + "</Value>"+
                        "</Eq>"+
                    "</Where>"+
                "</Query>";

 $().SPServices({
    operation: 'GetListItems',
    async: false,
    listName: 'Postagens',
    webURL: 'http://site/subsite/Lists/Postagens/',
    CAMLViewFields: '<ViewFields>'+
                        '<FieldRef Name="Curtir" />'+
                    '</ViewFields>',
    CAMLQuery : queryText,      
    completefunc: function (xData, Status) {
        $(xData.responseXML).SPFilterNode('z:row').each(function() {
            CurtirTot = $(this).attr('ows_Curtir');
        });
    }
});

I googled, but the closest result I got was "Connectivity failure"
Can anyone tell me if I need to set up something else in Sharepoint to work properly on Spservices or is there an error in the code ?

1 answer

1

The option webURL should indicate the path of a site. In its code it indicates the path of a list.

Modify the value of the option to contain the path only to the site, that is, assuming the site is called "Subsite" and stand in the way of the realm "website", would look like this:

...
    webURL: `'http://site/subsite/'`,
...
  • I tried to take out the "Weburl" parameter and it worked. Thank you

  • 1

    About this parameter, it should be used only when you are making requests from one site to another. If you are on the site itself blog, then he’s really expendable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.