0

I do not have direct access to my SharePoint server. I access the SharePoint data from a URL that is available only internal on my work VPN.

Is there a way in JAVA to query this URL and return data from it?

Edit - I found this syntax that returns a 200 OK like you suggested, but how do I now take it a step further to return specific data from a list

public class SharePointClientAuthentication {

public static void main(String[] args) throws Exception {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
        new AuthScope(AuthScope.ANY),
        new NTCredentials("username", "password", "https://hostname", "domain"));
CloseableHttpClient httpclient = HttpClients.custom()
        .setDefaultCredentialsProvider(credsProvider)
        .build();
try {
    HttpGet httpget = new HttpGet("http://hostname/_api/web/lists");

    System.out.println("Executing request " + httpget.getRequestLine());
    CloseableHttpResponse response = httpclient.execute(httpget);
    try {
        System.out.println("----------------------------------------");
        System.out.println(response.getStatusLine());
        EntityUtils.consume(response.getEntity());
    } finally {
        response.close();
    }
} finally {
    httpclient.close();
} 
}
}
0

The easiest way? Look at the SharePoint Online REST Services, here is a brief intro:

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service

If you have access to at least the Public SharePoint server by REST Call this can do it for you. Let me know if that helps or if this needs more clarity, thanks!

EDIT:

Java Has API's out there to make REST web service calls, not sure what they are exactly as my Java isn't the best, but it can be done.

  • Do I need the SP wsdl files to use the REST call you link to above? – Doctor Ford Dec 27 '18 at 18:14
  • Nope, no WSDL Required for REST calls, just shape your URL for your call into what you want to do. – tekiegreg Dec 27 '18 at 18:15
  • 1
    Excellent, I'll give this a whirl and see what I can come up with. Thank you! – Doctor Ford Dec 27 '18 at 18:16
  • 1
    Is there a full syntax example that shows how to connect with JAVA that you know? – Doctor Ford Dec 27 '18 at 18:47
  • Not offhand but I'm sure some Googling would yield something. My best suggestion for you is since REST works via simple browser calls, construct your REST URL to call SharePoint in Chrome and see the result in XML or JSON returned, continue to refine until you can build a Java Call that calls that URL and returns the result. Also recommended for beginners to REST, download a copy of SoapUI, it can help construct REST and SOAP/WSDL calls as well. – tekiegreg Dec 27 '18 at 19:43

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.