0

I have a list of tags with 2 columns, Title and Folder.

https://i.stack.imgur.com/WGgIz.png

I am currently querying the list using '/_api/web/lists/GetByTitle('Tags')/items' and am successfully retrieving the Title from the response body. I am unable to retrieve the value from the Folder column, though. In the response body there is a Folder value being returned but it is an object

{
  __deferred: {
    uri: "site/_api/Web/Lists(guid'##########')/Items(12)/Folder"
  }
}

Screenshot of column settings: https://i.stack.imgur.com/bVqD7.png

The Folder value I am looking for is a string. Any idea how I can retrieve both the Title and Folder values with the REST api?

4
  • What is the column type of Folder column? Aug 6, 2020 at 20:36
  • @DikshaPoddar the column type is a single line of text Aug 6, 2020 at 20:38
  • @Omiinahellcat, can you please attach the screenshot of column settings for Folder column to your question? Aug 7, 2020 at 5:24
  • @GaneshSanap added Aug 7, 2020 at 13:05

3 Answers 3

1

As per my understanding (by seeing the screenshots you attached), I think it is causing this issue because of using incorrect internal name of your Folder column.

Please check the internal name of your column using this method: Find the internal name of SharePoint column

Then you can use the REST endpoint like below:

<site-url>/_api/web/lists/getbytitle('Display Name of List')/items?$select=Title,InternalNameOfFolderColumn

Replace InternalNameOfFolderColumn with the internal name you got from above method.

Official documentation: Working with lists and list items with REST

Update from comments:

As per Dylan's comment:

I think the problem is because SharePoint allowed the creation of a field with the internal name of "Folder", which through the REST API is conflicting with the built-in Folder endpoint. I think the solution would be to create a new field with an internal name that is not exactly "Folder", and then change the display name back to "Folder", so that the internal name is not in conflict with the REST API.

7
  • I used the method and the internal name in the url is Field=Folder. So it should be correct, still not sure why the values for Folder are returning deffered uri. Aug 7, 2020 at 17:31
  • very strange! is there any real time data in this list or is it still in development? if it is still in development, can you please try deleting this column and adding it again with same name? Or try creating the column with same name in another list and check if it works there. Aug 7, 2020 at 17:49
  • I think the problem is because SharePoint allowed the creation of a field with the internal name of "Folder", which through the REST API is conflicting with the built-in Folder endpoint. I think the solution would be to create a new field with an internal name that is not exactly "Folder", and then change the display name back to "Folder", so that the internal name is not in conflict with the REST API. Aug 7, 2020 at 17:52
  • @DylanCristy Yes, I tried running this endpoint without creating a column with name folder and it was working (not giving any column missing errors). that means it is conflicting with the built-in folder endpoint as you mentioned. +1 for your suggestions. Aug 7, 2020 at 18:04
  • This is still in development, I will delete the column and give a different name and let you guys know. Aug 7, 2020 at 18:52
1

As both columns are Single Line of texts, the simple REST call should return their values.

However, try below REST API call to get specific columns only (Use internal names) -

/_api/web/lists/getByTitle('Tags')/items?$select=Title,Folder
1
  • This is supposed to work in theory, but I am getting incorrect response value for the Folder column. Instead of getting a single line of text ex: "PPT", the folder values that are being returned are all objects, ex: {__deferred:{uri: "sites/_api/Web/Lists(guid)/Items(#)/Folder"}} Aug 6, 2020 at 21:14
0

Try the below Rest API call, it should work for you:

/_api/web/lists/getByTitle('list')/items(1)/FieldValuesAsHtml?$select=Title,Folder

enter image description here

2
  • Returns {"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"en-US","value":"Item does not exist. It may have been deleted by another user."}} Aug 7, 2020 at 16:50
  • As the error said, this item with id 1doesn't exist. You could use the existing item in the rest api. Like items(12),or just use /_api/web/lists/getByTitle('list')/items/FieldValuesAsHtml?$select=Title,Folder to get all items. Aug 7, 2020 at 19:30

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.