1

I'm trying to call the SP 2016 on-prem REST API on 3rd party VUE.js application(cross domain), and struggling on the authentication issue.

  1. To avoid the cross domain issue, I try to call REST API via SP.RequestExecutor.js. But in Network tab, I see "401 Unauthorized" on the request of AppWebProxy.aspx when the following code runs.

    var executor = new SP.RequestExecutor(appweburl);
    executor.executeAsync(
    {
        url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists?@target='" + hostweburl + "'",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: successHandler,
        error: errorHandler
    });
    

1.2. When I try to test the REST API http://www.example.com/_api/Web/Lists('{guid}')/items, it shows below error -

{ "error": { "code": "-2147024891, System.UnauthorizedAccessException", "message": { "lang": "en-US", "value": "Access denied. You do not have permission to perform this action or access this resource." } } }

My question is that how to pass the authentication when I call the REST API in js code?

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.