0
votes

I am developing mobile application and implementing Office 365 file and folder operations to store and retrieve files with details. I have created a account in Office 365 and following this REST API document - https://msdn.microsoft.com/office/office365/APi/files-rest-operations.

I have also created some custom columns in my office 365 document library to store some meta data about my files like Description, City, State, Country, Zip etc.

I tried to read these values from my REST API call like below with required headers.

https://[MY_COMPANY_NAME].sharepoint.com/_api/v1.0/files/GetByPath('PATH_TO_FILE/icon.png')?&$expand=Description,City,State

I got the response successfully without any problems. But I didn't get my column values. I got only some default file properties like id, createdBy, last modified, name, eTag, size, type, webUrl etc.

I have searched lot in internet to read these column values by REST API and failed. Please anyone guide me to resolve this problem. Whether we need to any settings or permissions in Office 365 sharepoint.

Thanks

1

1 Answers

0
votes

The endpoint GET {base-url}/getByPath('{file-path}') returns File resource (Microsoft.FileServices.File) which returns Item resource properties and the following additional properties:

  • contentUrl string URL for downloading the file's content.
  • image ImageFacet Image metadata, if the file is an image. To get ImageFacet properties, use the $select query parameter in the request URL to include specific properties in the response.

Since you are trying to get properties of list item associated with a file, i would propose the following solution for that purpose:

/_api/web/getfilebyserverrelativeurl('{serverrelativeurl}')?$expand=ListItemAllFields

Example

The following request returns file properties from Shared with Everyone folder located in OneDrive for Business:

https://contoso-my.sharepoint.com/personal/jdoe_contoso_onmicrosoft_com/_api/web/getfilebyserverrelativeurl('/personal/jdoe_contoso_onmicrosoft_com/Documents/Shared%20with%20Everyone/UserGuide.docx')?$expand=ListItemAllFields