cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

REST access denied from nintex forms office 365

Jump to solution

I am trying to make a rest call to return user profile properties into a nintex from based on a people picker. The rest call I want to make works in the browser and returns all the profile properties, however when I try to run this from within a nintex form using jquery I am presented with the following 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."

I have followed the guide Retrieving User Profile Properties in a SharePoint 2013 Workflow - SharePoint Community  on giving app permissions and have done this for nintex forms app but I am still getting the error. Has anyone else tried using REST to get profile properties in nintex forms for office 365? or have you got any other method of doing this?

Tags (1)
Reply
7 Replies
Highlighted
Automation Master
Automation Master

Re: REST access denied from nintex forms office 365

Jump to solution

Hello martin townshend​ – It sounds like encountering a blocked cross-domain request. Are you making sure to utilize the app's context for your REST request? This is likely the culprit for permission related problems with REST.

See below for a quick sample of how I utilize REST within Nintex Forms. This sample writes to console an object array of all items within a "TEST" list.

var web;

var hostweburl;

var appweburl;

var pollSP;

NWF.FormFiller.Events.RegisterAfterReady(function () {

    pollSP = setInterval(checkSPLoad, 500);

});

function checkSPLoad() {

    if (clientContext) {

        window.clearInterval(pollSP);

        sharePointReady();

    }

}

function sharePointReady() {

    NWF$().ready(function () {

        hostweburl = decodeURIComponent(Utils.getQueryStringParameter('SPHostUrl'));

        appweburl = decodeURIComponent(Utils.getQueryStringParameter('SPAppWebUrl'));

        Data.getSomethingWithREST();

    });

}

var Data = {

    getSomethingWithREST: function () {

        var context;

        var factory;

        var appContextSite;

        var listName = "TEST";

        context = new SP.ClientContext(appweburl);

        factory = new SP.ProxyWebRequestExecutorFactory(appweburl);

        context.set_webRequestExecutorFactory(factory);

        appContextSite = new SP.AppContextSite(context, hostweburl);

        var executor = new SP.RequestExecutor(appweburl);

        executor.executeAsync({

            url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + listName + "')/items?&$orderby=Title&@target='" + encodeURIComponent(hostweburl) + "'",

            method: "GET",

            headers: {

                "Accept": "application/json; odata=verbose"

            },

            success: function (data) {

                var obj = JSON.parse(data.body);

                console.log(obj.d.results);

            },

            error: function (err) {

                alert(JSON.stringify(err));

            },

        });

    },

};

var Utils = {

    getQueryStringParameter: function (param) {

        var params = document.URL.split('?')[1].split('&');

        var strParams = '';

        for (var i = 0; i < params.length; i = i + 1) {

            var singleParam = params.split('=');

            if (singleParam[0] == param) {

                return singleParam[1];

            }

        }

    },

};

I've tested the above to be working (embedded JavaScript and Nintex Forms for O365).

Reply
Not applicable

Re: REST access denied from nintex forms office 365

Jump to solution

Thanks Patrick, I was able to get my rest call working using your suggestions.

Reply
Automation Master
Automation Master

Re: REST access denied from nintex forms office 365

Jump to solution

Glad I could help martin townshend​ – good luck!

Reply
milan_stojadino
Nintex Newbie

Re: REST access denied from nintex forms office 365

Jump to solution

Would you mind shareing your code with us?

How does your URL look like?

0 Kudos
Reply
Automation Master
Automation Master

Re: REST access denied from nintex forms office 365

Jump to solution

Milan Stojadinovic​ If the above code doesn't suffice, I've rolled my REST code snippet into a Xchange Marketplace asset (see below).

Using the SharePoint REST service inside Nintex Forms

0 Kudos
Reply
karthikm
Nintex Newbie

Re: REST access denied from nintex forms office 365

Jump to solution

Hello Martin,

Would you mind sharing the URL? How does it look like, I am trying to get the user profile properties but still getting access denied. 

Thanks,

Karthik

0 Kudos
Reply
ravish_eee
Nintex Newbie

Re: REST access denied from nintex forms office 365

Jump to solution

Hi Martin,

Could you please help me out to get the user profile data in nintex forms for office 365. I am getting access denied error whichever way I am trying, using rest api.

Thanks

0 Kudos
Reply