4

I'm starting to develop in SharePoint Online, but I don't arrive to do work spservices() with GetListItems().

I have create an application with napacloudapp

In this application I have put that :

<script language="javascript" type="text/javascript">

    $(document).ready(function() {

        $().SPServices({
            operation: "GetListItems",
            async: false,
            webURL: "https://mycompagny.sharepoint.com/sites/test",
            listName: "Contacts",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
                    $("#tasksUL").append(liHtml);
                });
                alert(xData.responseText);                  
            }
        });

    });

</script>

So when I run my project with my alert(xData.responseText); I can see

"the List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user."

I have added weburl parameter like Amal and bgmcoder said. Now in the console I have this error :

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
7
  • Do you have a list in your site with the name Contacts? Aug 5, 2016 at 13:41
  • Exactly do you have the list named contacts in your site?? Aug 5, 2016 at 15:05
  • Is the URL correct as per the last error? Does that web contains the list? Aug 5, 2016 at 15:21
  • I have the list Contacts in my site. I go directly to the list since the url mycompagny.sharepoint.com/sites/test/List/Contacts
    – Mathi
    Aug 5, 2016 at 15:35
  • @Mathi lists is under /Lists/ not /List/ Aug 8, 2016 at 10:03

3 Answers 3

2

You might have to enable the Custom Script setting in Sharepoint Online.

The settings page is in Sharepoint Admin Settings - the url is like this:

https://mycompany.sharepoint.com/layouts/15/online/TenantSettings.aspx

Custom Script Control whether users can run custom script on personal sites and self-service created sites. Note: changes to this setting might take up to 24 hours to take effect.

For more information, see http://go.microsoft.com/fwlink/?LinkId=397546

These are the options:

  • Prevent users from running custom script on personal sites
  • Allow users to run custom script on personal sites
1

You can pass the url of the site which has the list

webUrl: "http://weburl/"
2
0

Generally speaking, the webURL shouldn't look like this:

webURL: "https://mycompagny.sharepoint.com/sites/test",

My guess us that you really want

webURL: "/sites/test",

In other words, the webURL should be the relative path to the site where the list is located. However, you only need to specify the webURL if the list is not in the current context (site).

1
  • Marc, does it make a difference when it's https? Do the references to the JQuery and SPServices scripts also need the https, or should using relative links take care of this?
    – Erin L
    Aug 23, 2016 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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