1

I require assistance with Sharepoint. I've tried multiple ways to retrieve data from a list and have had little to no success, after much reading and searching I'm still no further ahead.

I am using a list made by another user, which I can add,edit and delete items from. When calling this list using SPServices I seem to hitting a wall. Here is my third attempt at trying to access the list and now I have received a 404 response and responsetext is null.

The URL is correct, cause it actually loads the list of values.

If i have an empty webURL parameter, the parameter of responsetext has a helpful SOAP response stating the following:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user.
    </errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x82000006</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>

Here is my call which when I define the webURL to point to the list, it always returns a http 404 with responseText=null no matter what the url is. This is not very helpful. The Url I am pointing to loads the list.

function getListItems_RFC(){
   var url = $().SPServices.SPGetCurrentSite() + 
                "/_vti_bin/listdata.svc/RFCExtract";
   console.log("getListItems_RFC() "+ url);
   $().SPServices({
            operation: "GetListItems",
            webURL: url,
            async: false,
            listName: "RFC Extract",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
            completefunc: 
               function (xData, Status) {
                  console.log(Status); //outputs error
                  console.log(xData); //outputs array responseText:null and status:404
                       $(xData.responseXML).SPFilterNode("m:properties").each(function() {
                      var liHtml = "<li>" + $(this).attr("d:Title") + "</li>";
                      $("#debug").append(liHtml);
                  });
               } 
       });
};

I have modified the url each possible way:

var url = $().SPServices.SPGetCurrentSite() + 
                    "/_vti_bin/listdata.svc/"; //responseText=null, status:404
var url = $().SPServices.SPGetCurrentSite();//responseText=null, status:404
var url = "" //responseText=soapresponse above, status:500

Why is this not working??? What am I doing wrong???

Snippet of Data that is seen when visiting the url: <**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="<**BASE_URL**>/_vti_bin/listdata.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">RFCExtract</title>
  <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract</id>
  <updated>2018-11-29T12:43:44Z</updated>
  <link rel="self" title="RFCExtract" href="RFCExtract" />
  <entry m:etag="W/&quot;1&quot;">
    <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(1)</id>
    <title type="text">Test</title>
    <updated>2018-11-28T15:07:57-05:00</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="RFCExtractItem" href="RFCExtract(1)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(1)/CreatedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(1)/ModifiedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(1)/Attachments" />
    <category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
        <d:Title>Test</d:Title>
        <d:Class m:type="Edm.Double">1</d:Class>
        <d:Status>Closed</d:Status>
        <d:Date m:type="Edm.DateTime">2010-11-01T00:00:00</d:Date>
        <d:RFCNumber m:type="Edm.Double">1</d:RFCNumber>
        <d:Id m:type="Edm.Int32">1</d:Id>
        <d:ContentType>Item</d:ContentType>
        <d:Modified m:type="Edm.DateTime">2018-11-28T15:07:57</d:Modified>
        <d:Created m:type="Edm.DateTime">2018-11-28T15:07:57</d:Created>
        <d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
        <d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
        <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
        <d:Version>1.0</d:Version>
        <d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
      </m:properties>
    </content>
  </entry>
  <entry m:etag="W/&quot;1&quot;">
    <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(2)</id>
    <title type="text">Test Record 2</title>
    <updated>2018-11-29T07:42:19-05:00</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="RFCExtractItem" href="RFCExtract(2)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(2)/CreatedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(2)/ModifiedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(2)/Attachments" />
    <category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
        <d:Title>Test Record 2</d:Title>
        <d:Class m:type="Edm.Double">2</d:Class>
        <d:Status>Pending</d:Status>
        <d:Date m:type="Edm.DateTime">2018-11-02T00:00:00</d:Date>
        <d:RFCNumber m:type="Edm.Double">2</d:RFCNumber>
        <d:Id m:type="Edm.Int32">2</d:Id>
        <d:ContentType>Item</d:ContentType>
        <d:Modified m:type="Edm.DateTime">2018-11-29T07:42:19</d:Modified>
        <d:Created m:type="Edm.DateTime">2018-11-29T07:42:19</d:Created>
        <d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
        <d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
        <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
        <d:Version>1.0</d:Version>
        <d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
      </m:properties>
    </content>
  </entry>
</feed>

Here are the results tested for each potential List Name:

  LIST_NAME         BASE_URL (Only)   BASE_URL+LIST_NAME  WEB_URL(B_N+L_N)
RFC Extract              404                 404               X
RFCExtract               404                 404               VALID
RFC%20Extract            404                 404               X
RFC_x0020_Extract        404                 404               X
0

Here is my sample code for your reference.

If you run the script in SharePoint online page, you could get url by _spPageContextInfo.webAbsoluteUrl

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            checkReservationStatus();
        });
        function checkReservationStatus() {
            var weburl = _spPageContextInfo.webAbsoluteUrl;
            var list = "mylist3";
            $().SPServices({
                operation: "GetListItems",
                webURL: weburl,
                async: false,
                listName: list,
                // get list name from passed variable lisTitle
                CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /></ViewFields>",
                completefunc: function (xData, Status) {
                    alert(Status);
                    $(xData.responseXML).SPFilterNode("z:row").each(function () {
                        status = $(this).attr("ows_Title");
                        alert(status);
                    })
                }
            })
            if (status == "Yes") {
                return "Yes";
            } else {
                return "No";
            }
        }
    </script>
  • The statement of _spPageContextInfo.webAbsoluteUrl returns undefined. I noted that you also changed the filter upon, the results I look at do not have the attributes of z:row or ows_Title. I have included a snipped of test data that I have been using to create a working process. – mcv Nov 30 '18 at 13:32
0

I tried your code and it worked fine with this.

 function getListItems_RFC() {
                var url = $().SPServices.SPGetCurrentSite() //+ "/_vti_bin/listdata.svc/RFCExtract";
                console.log("getListItems_RFC() " + url);
                $().SPServices({
                    operation: "GetListItems",
                    webURL: url,
                    async: false,
                    listName: "RFC Extract",
                    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
                    completefunc: function(xData, Status) {
                        console.log(Status); //outputs error
                        console.log(xData); //outputs array responseText:null and status:404
                        $(xData.responseXML).SPFilterNode("m:properties").each(function() {
                            var liHtml = "<li>" + $(this).attr("d:Title") + "</li>";
                            $("#debug").append(liHtml);
                        });
                    }
                });
            };

RFC Extract and RFCExtract are different. Use the actual name of the list.

  • Thank you for your reply. Where do I find the 'actual name'? I have referenced the list, XML and URL and I have seen 3 formats (RFCExtract, RFC Extract, and RFC%02Extract). I have tested them all. I would think that an error would be provided if it was a simple issues like that. I really want to to move forward and be capable of reading the list? I know that var url = $().SPServices.SPGetCurrentSite(); does work, but it's the next service of $().SPServices{ that is failing. It's frustrating to be honest, but I ain't giving up. – mcv Nov 30 '18 at 13:05
  • Also should the URL be the baseURL only? or should it be the URL to the actual list? BASE_URL = "http://example.com/sp/xxxx/"; LIST_URL = BASE_URL + "/_vti_bin/listdata.svc/RFCExtract"; – mcv Nov 30 '18 at 13:11
  • If my code worked fine, than are there permissions that i might be missing? For example, if on the list page, I have no access to List Settings. This is why I am asking about the actual name. I just found another naming convention inside HTML which is RFC_x0020_Extract – mcv Nov 30 '18 at 14:18
  • I've updated my answer and added full code. I'm getting success with this code. What I mean with actual name is the list name which when you entered all items view, not the url. Also you need at least read permission to read list items. Otherwise, you will get 404. – newbie Dec 3 '18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.