1

I'm trying to access from a j2ee application the REST api of MS Project Server 2013 which is part of Microsoft Project Online. The url is https://myCompany.sharepoint.com/sites/pwa/_api/ProjectServer/Projects

I use the following code:

String url = https://myCompany.sharepoint.com/sites/pwa/_api/ProjectServer/Projects
String username = "";
String pass = "";

try {
   Client client = Client.create();
   client.addFilter(new HTTPBasicAuthFilter(username, pass));
   WebResource webResource = client.resource(url);
   ClientResponse response = (ClientResponse)webResource.type(MediaType.APPLICATION_ATOM_XML).get(ClientResponse.class);
   InputStream inputStream = response.getEntityInputStream();
   String output = IOUtils.toString(inputStream);
   System.out.println("answer: " + output);
} catch (Exception e) {
   e.printStackTrace();
}

The type of the response I receive is 403.

<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <m:code>-2147024891, System.UnauthorizedAccessException</m:code>
  <m:message xml:lang="en-US">Access denied. You do not have permission to perform this action or access this resource.</m:message>
</m:error>

This, I guess, has to do with https, so my implementation is not appropriate. Can anyone suggest me how I could implement my restful client in order to achieve getting a normal response when accessing this https url?

jkonst
  • 433
  • 6
  • 20

0 Answers0