Sharepoint API for Java

前端 未结 3 1947
清歌不尽
清歌不尽 2020-12-21 12:03

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

3条回答
  •  攒了一身酷
    2020-12-21 12:23

    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": "" +
            "" + query + "" +                       
          ""
        }
      },
    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.

提交回复
热议问题