0

i have developer site with my sharepoint hosted app. From this app i want to load list data (via rest) from different site.

Developer sitecollection: http://sps1-dev:8087/sites/devsite

Sharepoin hosted app is running here: http://app-71d0bd0ca59c3e.xxxdev.sk:8087/sites/devsite/CDR

List with data (different farm): https://intranet.xxx.xx/sites/ourpeople

AppManifest.xml:

RemoteEndpoints

RemoteEndpoint Url="https://intranet.xxx.xx/sites/ourpeople"

RemoteEndpoints

Script:

var url = "https://intranet.xxx.xx/sites/ourpeople/_api/web/lists/getbytitle('EMP_2019_03')/items"; 

$.ajax({ url: "../_api/SP.WebProxy.invoke", type: "POST", data: JSON.stringify( { "requestInfo": { "__metadata": { "type": "SP.WebRequestInfo" }, "Url": url, "Method": "GET", "Headers": { "results": [{ "__metadata": { "type": "SP.KeyValue" }, "Key": "Accept", "Value": "application/json;odata=verbose", "ValueType": "Edm.String" }] } } }), headers: { "Accept": "application/json;odata=verbose", "Content-Type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: successHandler, error: errorHandler }); function successHandler(data) { console.log(data); } function errorHandler() { console.log('error'); }

enter code here

Error:

d: Invoke:

Body: "The remote server returned the following error while establishing a connection - 'Unauthorized'."

Headers: {__metadata: {…}, results: Array(0)} StatusCode: 401

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.