1

我使用 Project Online 与 MS Project Server 2013 一起托管 Sharepoint 2013。当我尝试从我的 Restful Jersey 客户端访问https://my_company.sharepoint.com/sites/pwa/_api/ProjectData/Projects并提供正确的凭据后,我获取状态类型为 403 的响应。响应的文本正文对应的 String 为以下 xml:

<?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>

我用来验证和访问 Rest API 的代码如下:

String url = "https://myCompany.sharepoint.com/sites/pwa/_api/ProjectData/Projects";
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();

    try {
        String output = IOUtils.toString(inputStream);
        System.out.println("output: "+output); 
    } catch(IOException e) {
        e.printStackTrace();
    }
} catch (Exception e) {
    e.printStackTrace();
}

我猜这个问题在某种程度上与 Pr​​oject Online 使用的 https 协议有关,但我不确定。任何帮助,将不胜感激。

4

1 回答 1

2

两件事:1-如果您使用 Project Online,它使用 OAuth 无基本身份验证 2-用户必须在启用“访问 Project Server Reporting Service ”权限的组中

于 2015-04-23T21:26:08.747 回答