Reputation: 416
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
Upvotes: 2
Views: 6911
Reputation: 51
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
Upvotes: 5
Reputation: 416
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.
Upvotes: 3