Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Steps that I am trying to perform the following steps through Java:

1) Connect to a sharepoint site with a given URL.

2) Get the list of files listed on that page

3) Filter the files using Modified date

4) Perform some more checks using Create Date and Modified Date

5) And finally save that file(s) into the Unix box.

As of now, I am able to access a particular file and read through it. However I need to get hold of file's metadata before reading it. Is there an API or a way to do all these in Java.

Thanks

With SharePoint 2013, the REST services will make your life easier. In previous versions, you could use the good old SOAP web services.

For instance, you could connect to a list with this query on the REST API:

http://server/site/_api/lists/getbytitle('listname')/items

This will give you all items from that list. With OData you can do additional stuff like filtering:

$filter=StartDate ge datetime'2015-05-21T00%3a00%3a00'

Additionally, you can provide CAML queries to these services, allowing you to define detailed queries. Here's an example in Javascript:

var re = new SP.RequestExecutor(webUrl);
re.executeAsync({
url: "http://server/site/_api/web/lists/getbytitle('listname')/GetItems",
method: 'POST',
headers: { 
    "Accept": "application/json; odata=verbose",
    "Content-Type": "application/json; odata=verbose"
body: { 
    "query" : {
      "__metadata": {
        "type": "SP.CamlQuery" 
      "ViewXml": "<View>" +
        "<Query>" + query + "</Query>" +                       
      "</View>"
success: successHandler,
error: errorHandler

If all of this doesn't provide enough flexibility, you might as well take these list items in memory and do additional work in your (server side) code.

@NicholasDiPiazza Of course but why would you want to do that if you can use modern technologies/standards like REST? – hbulens Feb 16, 2017 at 12:48

I have developed a Sharepoint Rest API java wrapper that allows you to use most common operations of the rest API.

https://github.com/kikovalle/PLGSharepointRestAPI-java

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.