0

I have a document library to which I added some extra columns, mainly important one is "country".

I can GET the list of Files using the following URL:

/web/getFolderByServerRelativeUrl('/path/to/my/folder')/Files

However, to get the extended property for a given file, I have to send a second GET request to:

/web/getFileByServerRelativeUrl('/path/to/my/folder/filename.ext')/Properties

This is kind of bad for me because I need to first send a GET request to get the list of files, and then for every single file I'd have to send a GET request to get the country information from the Properties URL.

Is there any way to get those properties for ALL files in a single request?

EDIT1: I found out about the ?&expand=Properties

This returns the Properties inside my List GET request, which is good! I now get the data in one request. But now I have no idea how to map this back to my File object.

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" type="application/atom+xml;type=entry" title="Properties" href="Web/GetFileByServerRelativeUrl('/sites/nortal/MyLib/Nortal/EE149291%20-%20Estonia%20-%20Shell/Invoices/catalina.2015-08-17%20(12).log')/Properties">
     <m:inline>
        <entry>
           <id>https://hydeandassociates.sharepoint.com/sites/nortal/_api/Web/GetFileByServerRelativeUrl('/sites/nortal/MyLib/Nortal/EE149291 - Estonia - Shell/Invoices/catalina.2015-08-17 (12).log')/Properties</id>
           <category term="SP.PropertyValues" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
           <link rel="edit" href="Web/GetFileByServerRelativeUrl('/sites/nortal/MyLib/Nortal/EE149291%20-%20Estonia%20-%20Shell/Invoices/catalina.2015-08-17%20(12).log')/Properties" />
           <title />
           <updated>2015-08-19T12:36:47Z</updated>
           <author>
              <name />
           </author>
           <content type="application/xml">
              <m:properties>
                 <d:vti_x005f_metadatanextbsn>100</d:vti_x005f_metadatanextbsn>
                 <d:vti_x005f_replid>rid:{62C6C0D6-FAAB-44B8-9EA5-1B4EE8DC3E35}</d:vti_x005f_replid>
                 <d:vti_x005f_level m:type="Edm.Int32">1</d:vti_x005f_level>
                 <d:ContentTypeId>0x0101000E4CD36A88C99145A1289070EF86E196</d:ContentTypeId>
                 <d:vti_x005f_setuppathversion m:type="Edm.Int32">15</d:vti_x005f_setuppathversion>
                 <d:vti_x005f_rtag>rt:62C6C0D6-FAAB-44B8-9EA5-1B4EE8DC3E35@00000000002</d:vti_x005f_rtag>
                 <d:vti_x005f_sourcecontrolversion>V1.0</d:vti_x005f_sourcecontrolversion>
                 <d:vti_x005f_sourcecontrolcookie>fp_internal</d:vti_x005f_sourcecontrolcookie>
                 <d:vti_x005f_filesize m:type="Edm.Int32">41326</d:vti_x005f_filesize>
                 <d:vti_x005f_modifiedby>i:0#.f|membership|nortal@hydeandassociates.com</d:vti_x005f_modifiedby>
                 <d:Country>Various</d:Country>
                 <d:vti_x005f_docstoretype m:type="Edm.Int32">0</d:vti_x005f_docstoretype>
                 <d:vti_x005f_internalversion m:type="Edm.Int32">513</d:vti_x005f_internalversion>
                 <d:vti_x005f_nextbsn>150</d:vti_x005f_nextbsn>
                 <d:vti_x005f_parserversion>16.0.0.4316</d:vti_x005f_parserversion>
                 <d:vti_x005f_docstoreversion m:type="Edm.Int32">2</d:vti_x005f_docstoreversion>
                 <d:vti_x005f_author>i:0#.f|membership|nortal@hydeandassociates.com</d:vti_x005f_author>
                 <d:vti_x005f_foldersubfolderitemcount m:type="Edm.Int32">0</d:vti_x005f_foldersubfolderitemcount>
                 <d:vti_x005f_contentversionisdirty>false</d:vti_x005f_contentversionisdirty>
                 <d:vti_x005f_timecreated m:type="Edm.DateTime">2015-08-19T11:31:04</d:vti_x005f_timecreated>
                 <d:vti_x005f_metainfoversion m:type="Edm.Int32">2</d:vti_x005f_metainfoversion>
                 <d:vti_x005f_contenttag>{62C6C0D6-FAAB-44B8-9EA5-1B4EE8DC3E35},2,1</d:vti_x005f_contenttag>
                 <d:vti_x005f_canmaybeedit>true</d:vti_x005f_canmaybeedit>
                 <d:vti_x005f_nextbsnallocated>150</d:vti_x005f_nextbsnallocated>
                 <d:vti_x005f_folderitemcount m:type="Edm.Int32">0</d:vti_x005f_folderitemcount>
                 <d:vti_x005f_timelastmodified m:type="Edm.DateTime">2015-08-19T11:31:10</d:vti_x005f_timelastmodified>
                 <d:vti_x005f_parentid>{4605B4EF-995B-4EC4-BAC0-454B99D1F64A}</d:vti_x005f_parentid>
                 <d:vti_x005f_candeleteversion>true</d:vti_x005f_candeleteversion>
                 <d:vti_x005f_nexttolasttimemodified m:type="Edm.DateTime">2015-08-19T11:31:04</d:vti_x005f_nexttolasttimemodified>
                 <d:vti_x005f_title />
                 <d:vti_x005f_contentversion m:type="Edm.Int32">1</d:vti_x005f_contentversion>
                 <d:vti_x005f_etag>"{62C6C0D6-FAAB-44B8-9EA5-1B4EE8DC3E35},2"</d:vti_x005f_etag>
                 <d:vti_x005f_timelastwritten m:type="Edm.DateTime">2015-08-19T11:31:04</d:vti_x005f_timelastwritten>
                 <d:vti_x005f_streamschema m:type="Edm.Int32">66</d:vti_x005f_streamschema>
              </m:properties>
           </content>
        </entry>
     </m:inline>
  </link>

2 Answers2

0

You can try this instead:

/_api/Web/Lists/GetByTitle('Document Library')/Items?$expand=File

This will not only retrieve the file properties, but the list item properties as well.

wjervis
  • 5,738
  • 24
  • 45
0

So the correct answer for me is added in the original post.

I added the ?&expand=Properties to the URL - which expanded the properties inside the same request.

I then had to update my (Java) classes that represent my JSON data to reflect the same changes. Note that I did use JSON in my responses rather than XML as above mentioned.