Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Sharepoint-hosted app ProjectData REST API calls getting 401 unauthorized error when site is accessed not on the server

$
0
0

I'm trying to query the PWA ProjectData endpoint for assignment information from a SharePoint-hosted app. The query is successful in testing. So, I've published and uploaded the app to SharePoint, and attempted to access it from my PWA instance. This works in Internet Explorer on the server running SharePoint and Project Server 2013, but not from any other computer or in Chrome. I am an administrator so should have full rights to the ProjectData endpoint.

Here is my query:

$.support.cors = true;
    $.ajax({
        url: spHostUrl + "/_api/ProjectData/Resources(guid'" + me.myId + "')/Assignments",
        dataType: "json",
        type: "GET",
        contentType: "application/json",
        data: "",
        beforeSend: function (xhr) {
            xhr.setRequestHeader("ACCEPT", "application/json; odata=verbose");
        },
        success: function (doc, text, xhr) {
            for (var x in doc.d.results) {
                // Do stuff
            }
        },
        error: function (x, text, o) {
            $('#message').text(x + text + o);
        }

    });

Here's what my request header gets turned into:

OPTIONS http://server.com/pwa/_api/ProjectData/Resources(guid'c4b3a7c4-6cdc-e311-8c25-0022198e7bfe')/Assignments HTTP/1.1
Accept: */*
Origin: http://app-5b32c2bd5a6d8a.server.com
Access-Control-Request-Method: GET
Access-Control-Request-Headers: content-type, accept
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: msproject.itac-net.com
Content-Length: 0
DNT: 1
Connection: Keep-Alive
Pragma: no-cache

And here's the response header:

HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/7.5
SPRequestGuid: 51caa49c-e5d6-f0a9-0031-80c5340cd773
request-id: 51caa49c-e5d6-f0a9-0031-80c5340cd773
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 4
SPIisLatency: 1
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 15.0.0.4420
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
Access-Control-Allow-Origin: *
Date: Tue, 15 Jul 2014 14:41:05 GMT
Content-Length: 16
Proxy-Support: Session-Based-Authentication

401 UNAUTHORIZED


I've tried scouring the internet, but cannot figure out what I am doing wrong. Do you think it's more likely a SharePoint or PWA setting issue than a programming issue?

Please help! Thank you. 


Viewing all articles
Browse latest Browse all 5347

Trending Articles