3

We are in the process of integrating from Sharepoint 2007 to Sharepoint 2013. We have a java based application using Sharepoint 2007 SOAP based webservices.

In Sharepoint 2013 we are using the REST API. And I am not seeing an obvious way to make a single call to get a list of documents for Shared Documents and have it include the Author's name.

I am calling to this REST endpoint:

https://www.acme.org/sites/PortalTest/_api/Web/GetFolderByServerRelativeUrl('/sites/PortalTest/Shared%20Documents')/Files?$select=*

I do get an Author property back, but it points to another REST end point (partial JSON response):

 "Author":{ "__deferred":{ "uri":"https://www.acme.org/sites/PortalTest/_api/Web/GetFileByServerRelativeUrl('/sites/PortalTest/Shared%20Documents/Test.docx')/Author" } 

Now I could make separate calls to get the Author information, but I'd rather not do it that way.

Is there anyway to make one call to get the documents in a Shared Documents folder that will include the author's name using the Sharepoint 2013 REST API?

EDIT TO ADD:

I found the answer. Adding the "expand" parameter will flush out deferred properties:

https://www.acme.org/sites/PortalTest/_api/Web/GetFolderByServerRelativeUrl('/sites/PortalTest/Shared%20Documents')/Files?$expand=Author

2 Answers 2

1

Try this query

?$select=Author/Id,Author/Name,Author/Title,Editor/Id,Editor/Name,Editor/Title,*&$expand=Author,Editor 
0

I was myself looking for an answer to this problem today. But whenever I attempted to add the query parameters to the URL straightaway I got an error:

A potentially dangerous Request.Path value was detected from the client (?)

So those of you that are also bothered by the above error message, you might want to try the following:

Endpoint (taking from the question): https://www.acme.org/sites/PortalTest/_api/Web/GetFolderByServerRelativeUrl(@a1)/Files

Query parameters (declare them separately):

@a1: "/sites/PortalTest/Shared%20Documents" $expand:"Properties,Author,CheckedOutByUser,ModifiedBy" (Depending on which ones you need. The entire list is available here)


Note: I am invoking the endpoints from my Java middleware and for that I'm using Client, WebTarget and Invocation.Builder from the javax.ws.rs.client namespace.

Client client; // Construct your client here with your token, secret and other attributes WebTarget target = client.target("https://www.acme.org/sites/PortalTest/_api/Web") .path("/GetFolderByServerRelativeUrl(@a1)/Files") .queryParam("@a1", "%27%2Fsites%2Fdms%5Fo2%2FShared%20Documents%27") // encoded! .queryParam("$expand", "Properties,Author,CheckedOutByUser,ModifiedBy"); Builder request = target.request(); //... 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.