How to get file parameters using REST

I apologize for a stupid question. I am new at SharePoint. The task looks very basic, but solution eludes me for several days.

In SharePoint  I have a Document Library, a number of document sets and some files uploaded to that document sets. Files have custom parameters. I need in a Java application  to craft a HTTP get request that for a diven document set name will extract all parameters of all files and return them as a JSON object.

I tried  request like:

<end point>/_api/web/GetFolderByRelativeUrs(</Document Library>/<Document Set>/files. This request returns properties of all files in the document set, but not custom properties.

I  tries request like:

<end point>/_api/lists/getByTitle<Document Library>/items?@Filter=??? This request returns custom property, but only for a document set. I do not know how to dig deeper.

I tries to add ListItemAllFields to the end of the first query, but it returns failure. It does not understand ListItemAllFields at this level.

I also tries something like this:

<end point>/_api/web/GetFolderByRelativeUrs(</Document Library>/<Document Set>/files('<file name>'/ListItemAllFields.

This query does return the file property, but not in a standard REST format so my parser cannot recognize it. In addition this query requires knowledge of the file name, that I do not have.

Please help.

August 21st, 2015 8:34pm

May I add some clarification to my question above.

My SharePoint site has a number of Content Types. One of them is used to add parameters (properties, metadata?) to files in all document sets in my Document Library. This Content Type has been created by the SharePoint Administrator. I do not know how SharePoint "knows" that it should apply this particular Content Type to every file added to any Document Set from that Document Library , but it does this. When I select a file and open its property page  I can see/modify the properties, listed in this Content Type.

Now, from my Java program (outside the server) I issue a get request like:

<end point>/_api/web/GetFolderByRelativeUrl(</Document Library>/<Document Set>/files

with headers: { "accept": "application/json; odata=verbose" }

I expect to receive a result in the JSON format that will lists all files in a given Document Set and all properties of that files, as they are specified in the Content Type. I do receive all files with their properties, but that properties are different from those specified in the Content Type. They obviously relate to the files, but they are different. May be they are some default properties.

So my first question is is this a normal behavior? Is it by design that this request returns properties that are different from those specified in the Content Type? May be it is just an error in the SharePoint configuration?

If this expected, my second question is how can I extract my custom properties, properties corresponding to the Content Type, used to add properties to the file?

Thank you.

Lev Tannen

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 11:12pm

Hi Lev,

We can use the following URI to get all the document items contains the document set and files.

/_api/web/lists/getbytitle('Document Library')/items

Best Regards,

Dennis

August 25th, 2015 2:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics