2

I faced a problem using the _api/lists/GetByTitle() with the Sharepoint default document library "Documents". This list title is automatically translated in all language (in Italian is "Documenti") inside the platform and also as output of other REST service as _api/lists. However if I use "Documenti" as title for the GetByTitle it returns an error. Instead if I put "Documents" it works as expected.

My spfx app make the user search a document by following this steps: 1) Select a library from a drop down list filled due to _api/lists 2) Use a Picker to find a document in the library selected at step 1. Picker show results according to what user type by performing a _api/lists/GetByTitle('Title')call.

This approach works every time except with Documenti since it is not the real library title (even if _api/Lists say so).

So I was wondering if there is a way to make it work with translated Title. Or if is it possible to retrieve the real title when using _api/lists and not the translated one. Does anyone faced this issue before?

Here you can see how calling _api/Lists you obtain Title "Documenti"

<d:TemplateFeatureId m:type="Edm.Guid">00bfea71-e717-4e80-aa17-d0c71b360101</d:TemplateFeatureId>
<d:Title>Documenti</d:Title>
</m:properties>
Tarick Welling
  • 3,119
  • 3
  • 19
  • 44

1 Answers1

0

To build the dropdown list, we can use set the option value with list id, option text with list Title.

Then get list items using the REST API endpoint below.

/_api/Web/Lists(guid'<list id>')/items

Example:

/_api/Web/Lists(guid'0ed7g5fa-1de2-49a8-a81a-d282b6d37620')/items
LZ_MSFT
  • 4,079
  • 1
  • 8
  • 9
  • Thanks! This sure is a solution. However I have a lot of other logic after the "Select file" step (which include Flows) where the Title information is used always with GetByTitle and I would like to avoid change everything. Is there another solution to this problem? – Marco Nitti Jul 09 '19 at 13:55
  • If you retrieve using _api/lists/getbytitle('ListName'), that 'ListName' string is language-dependent if the list name has been localized. So we have to use the GUID to do the query in REST API. – LZ_MSFT Jul 10 '19 at 01:28
  • you should remove guid and use like this: /_api/Web/Lists('{0ed7g5fa-1de2-49a8-a81a-d282b6d37620}')/items – saber tabatabaee yazdi May 09 '21 at 12:49