2

I'm having problems to get lists throught the REST API. I'm calling: /_api/web/lists/getbytitle('<list title>')

I'm getting an error (List doesn't exists) with that libraries named with more than 1 word. For example I'm not able to get "Site Assets". My sharepoint is in spanish so the titles when i call /_api/web/lists are in spanish.

I tried:

getbytitle('Activos del sitio') //Spanish Name
getbytitle('Site Assets')

Tried replacing the spaces with %20 and x0020:

getbytitle('Activos%20del%20sitio') //Spanish Name
getbytitle('Site%20Assets')
getbytitle('Activos_x0020_del_x0020_sitio') //Spanish Name
getbytitle('Site_x0020_Assets')

Tried with the RootFolder.Name

getbytitle('SiteAssets')

Tried on javascript using encodeURIComponent() with the list name.

Nothing works. I'm getting mad with it! Any Help?

Thanks!

9
  • 1
    Maybe use /_api/web/lists?$select=Title,Id which will return the Titles of all the lists. Then you'll know what value it is. You call also use the Id [guid] like /_api/web/lists(guid'#########')
    – Rothrock
    Commented Sep 12, 2019 at 17:44
  • thanks Rothrock. with /_api/web/lists?$select=Title,Id I get the same title as I posted (Activos del sitio). WIth the GUID works fine, so can be an alternative solution. Thank you very much. I will wait for a solution with the title for a time
    – xero399
    Commented Sep 12, 2019 at 17:54
  • Glad that helps you a bit. Did you try getbytitle('Site Assets') no encoding, no special characters, just a plain-ol-space? I've never worked with a site other than English. You could also try the Spanish name with no encoding.
    – Rothrock
    Commented Sep 12, 2019 at 18:12
  • yes, it was my first try. Not working
    – xero399
    Commented Sep 12, 2019 at 18:24
  • Are you using some kind of tool to help debug the issue? I like to use Restlet client in my chrome browser to test statements. Does it work when it hasn't been saved into a js file somewhere? Also what do you get if you do console.log(" ".charCodeAt(0))
    – Rothrock
    Commented Sep 12, 2019 at 18:46

3 Answers 3

1

You can use the List GUID in the REST API. Go to Library Settings and in the URL you will fin the GUID as shown in image below. enter image description here

Remove the "%7B" from the start and "%7D" from the end and use it in the rest api as shown in example below (replace the GUID with your GUID).

https://spdev.sharepoint.com/sites/SPTeam/spanish/_api/web/lists('85851fae-11b4-4c3f-8578-918b2c320bb5')
1
  • The problem is that I'm coding a javascrip app so I can't get it from de browser but I can do the REST call with the List ID as sugested. Thanks for the answer but has to be a solution to use getbytitle()
    – xero399
    Commented Sep 12, 2019 at 18:00
1

The following code for your reference.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var listTitle="Activos del sitio";
listTitle=encodeURIComponent(listTitle);
$.ajax({
        url:  _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('"+listTitle+"')",                                
        type: "GET",
        headers: {"Accept": "application/json;odata=verbose" },
        success: function(data){
            alert(data.d.Title);
        },
        error: function () {
            //console.log("Failed to get details");
        }
    });
});
</script>

enter image description here

1
  • That's exactly what I'm doing. I think it's a problem with the Sharepoint translation, cause the titles are shown in spanish but, for example, for Site Assets, in the URL is SiteAssets and the title is "Activos del sitio"
    – xero399
    Commented Sep 13, 2019 at 7:23
0

I am facing the same problem. My current hypothesis: There is a Sharepoint installation language, which in my case I assume to be English (don't know how to check). If I set my user language (Office Profile) via the arcane Delve/help settings to German then spClient.web.lists.get() returns the Title field in German. However, using that name in spClient.web.lists.getByTitle('German Title') returns 404.

Setting the Office Profile to English (installation language) I get an English title and that one works with getByTitle().

So to me it looks like you have to use the Title in the language of your Sharepoint installation.

2
  • Did you find a solution to this? I want to do something that is language independent. Is this something to do with "Metadata Language"? Can that be changed for an AddIn?
    – moviaa
    Commented Feb 29, 2020 at 13:09
  • My solution was to use the English title as all our Sharepoint installations are in English. My comment above was just a hypothesis which I didn't further investigate hoping someone else here could chime in and confirm or deny it.
    – mplwork
    Commented Mar 2, 2020 at 10:56

Your Answer

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

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