2

I have a Picture Library with folders within. Root folder contains another folders which named by years. Each year folder contains several album folders. And at least each album foilder contains pictures. I created new Boolean field 'IsCover' which defines cover image for album. Then I try to get album folders with files via REST API and I want to know which file is cover, but response does not contain such field.

http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files

"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{4E99ABFD-51A3-460F-9B34-1A1962F3C2CF},1,2",
"CustomizedPageStatus": 0,
"ETag": "\"{4E99ABFD-51A3-460F-9B34-1A1962F3C2CF},1\"",
"Exists": true,
"Length": "98331",
"Level": 1,
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "IMG_3474.JPG",
"ServerRelativeUrl": "/MediaGallery/2016/NY/IMG_3474.JPG",
"TimeCreated": "2016-03-20T21:00:27Z",
"TimeLastModified": "2016-03-20T21:00:27Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0"

If I try to get all items in library, that's ok, it shows me my field.

http://portal/_api/web/lists('guid')/Items

I tried to get fields with $select but it doesn't work.

http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files&$select=Name,Files/ServerRelativeUrl,Files/IsCover
5
  • For SharePoint-specific questions, please see the SharePoint Stack Exchange (sharepoint.stackexchange.com) site. Commented Mar 28, 2016 at 7:21
  • When you say 'it doesn't work', what error does it give you? I think you may have a problem with your query syntax. Commented Mar 28, 2016 at 13:49
  • @AlexChance I mean it does not work properly. It returns result but without my custom field IsCover. Commented Mar 28, 2016 at 20:24
  • If you try running just this http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files without the $select does it return the results with all fields? If you need files and folders use ?$expand=Files,Folders Commented Mar 28, 2016 at 20:49
  • @AlexChance It returns only standard fields, not custom. I wrote list of these fields in my first code example. Commented Mar 29, 2016 at 7:43

2 Answers 2

5

I know this is nearly a year old but I had a similar issue with trying to find custom columns within a document library, here had the answer for me;

   
var baseUrl = “/_api/Web/GetFolderByServerRelativeUrl(‘Pages/Landing Pages’)/Files?”;
var selectQuery = “$select=ListItemAllFields/ID,ListItemAllFields/Title,ListItemAllFields/FileRef,ListItemAllFields/Modules&”;
var expandQuery = “$expand=ListItemAllFields”;
var combinedUrl = baseUrl + selectQuery + expandQuery;

Just change the ID,Title etc for your column names

Thanks

Iain

Sign up to request clarification or add additional context in comments.

1 Comment

This! Expanding the ListItemAllFields actually helped in my case. /_api/Web/GetFolderByServerRelativeUrl('/DocLib')/Files?$expand=ListItemAllFields is my request url now. Thank you! :)
3
http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files

This request contrains only fields for file content type. To view fields from list item you should add ListItemAllFields to $expand parameter.

http://portal/_api/web/getfolderbyserverrelativeurl('mediagallery/2016/')/Folders?$expand=Files,Files/ListItemAllFields

This query will return list item and custom fields in ListItemAllFields section.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.