I'm working on a Java-Application that integrates with SharePoint. The different SharePoint services are currently requested via the SOAP API. I am now working on an abstraction layer to also integrate with SharePoint 2013 over the REST API. At the moment I have some Problems understanding the differences in querying fields via REST or SOAP (using GetListItems of lists.asmx).

What I learned until now:

  1. /_api/web/lists(guid)/items?$select=ID,FileRef I can directly select specific fields
  2. Fields of relationships can be selected with $select=Author/EMail&$expand=Author
  3. In the REST Version, I have to prefix fields that begin with an underscore by OData_, e.g. $select=OData__UIVersionString
  4. The internal name of SharePoint fields is encoded: File Size => File_x0020_Size

What I don't understand:

  • Why can't I perform a request with $select=File_x0020_Size? When I try it like this, I get the error "The field or property 'File_x0020_Size' does not exist". But when I go to /_api/web/lists(guid)/fields, the field is clearly available. With the SOAP service, this scenario works without problems.
  • Relationships can be expanded (see 2.) in the REST API. How can this be done in the SOAP API? When I add <FieldRef Name="Author" /> to my request, I get something like ows_Author="12;#Username" in the result. But how can I select a specific property, e.g. EMail?

I hope my description of the problem is understandable and that someone can help bring some light into my understanding of SharePoint.

  • Is your question what you need to put for the 'File_x0020_Size' field, or what the differences for selecting fields between SOAP and REST are, as your title states? – wjervis Jun 26 '14 at 16:22
  • Can you show the URL used for the REST call? – wjervis Jun 26 '14 at 16:27
  • Ok, I'll try to be a bit more specific: perhaps "inconsistency" instead of "difference" between SOAP/REST might be a better description. Until now my understanding (coming from SOAP) was, that I can just select ANY field that is defined in a list by specifying a FieldRef with the field name as an argument, which works in SOAP. In REST, the equivalent seems to be a $select=FieldName. However, a select with my example (File Size) doesn't work, which is an inconsistency in my opinion. But why? Is File Size a special field? Are there more of these "special" fields? Am I making the request wrong? – Dave Jun 26 '14 at 22:40
  • Supplement: my request for the file size was /_api/web/lists(guid)/items?$select=File_x0020_Size. To view the available fields of the list i'm using /_api/web/lists(guid)/fields. – Dave Jun 26 '14 at 22:52
  • you may use for author specific properties like this "/_api/web/lists/getbytitle('" + LIST TITLE + "')/items?&select=,Author/Id,Author/JobTitle,Author/Title,Author/Department,Author/EMail,Author/Name,Likers/Id,Likers/Name,Likers/Title,AttachmentFiles&$expand=Author,Likers,AttachmentFiles"; – Yavuz Sep 5 '16 at 15:20

For the REST API, file size is returned in a field called 'Length' when you request a specific file object like with:

/_api/web/getfilebyserverrelativeurl('/<folder name>/<file name>')


EDIT1: re-read question and realize you probably want the size of all the files in a list, which you need to retrieve all the files in a folder for... you would still use Length property though and it is still in bytes

/_api/web/GetFolderByServerRelativeUrl('/<Library Name>')/Files?$select=Length

EDIT2: If you are really asking 'why are these APIs not consistent with each other?' which seems to be what you have clarified -- then good luck finding that answer! You'll probably find many little differences because they were implemented by different (or mostly different) development teams and each has its own external standard that it attempts to implement.

| improve this answer | |

I cannot tell you why you cannot simply select File_x0020_Size, nor can I tell you why you cannot select other fields in REST. I can, however tell you the REST url to retrieve document file sizes:

| improve this answer | |

I did a lot of testing today and found out that all the fields I can't select are so called Managed Metadata Columns. And these unfortunately can't be selected in a list query with the REST API.

| improve this answer | |
  • I've selected Managed Metadata columns using REST. In fact, I have to use REST in Designer Workflows to read Managed Metadata columns. And the File Size field is a lookup field. – wjervis Jun 27 '14 at 11:10

My answer comes in a little bit late, but you can select the file size in your REST query with $select=FileSizeDisplay.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.