cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Automation Master
Automation Master

REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

I have recently upgraded to the latest version of Nintex Forms for Office 365 (1.2.3.0). After doing so, I am encountering a 403 access denied error when performing REST calls to create or update SharePoint list items from within my form.

I was able to bypass the 403 error by forcing SP.RequestExecutor.js to be loaded (contradictory to best practices : Nintex Forms O365 - Getting SharePoint ClientContext Do's and Dont's), but with this success comes some other issues within the form itself like form controls (lookups) not loading properly.

 

I believe I can state with certainty that this error I'm seeing spawns from recent updates on the product. Before fully upgrading, I had the same Nintex Form and embedded code running on two different tenants. The tenant with the latest update (v. 1.2.3.0) was failing whereas the previous version was working fine.

 

Perhaps the development pattern for interacting with Client Context has changed with the latest code base? I've attached a sample form and embedded JavaScript sample. This sample:

  1. Demonstrates the retrieval of SharePoint list data through REST (written to console) – working
  2. Demonstrates my previously working approaching for creating SharePoint list items using REST – not working
    1. initiates from a JavaScript button on the form itself for testing purposes.
  3. Dependency : the above are wired up to GET/POST data to a list named TEST 

Example of error:

Embedded JavaScript Code:

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"; // SharePoint list dependancy


        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);
                // log to console for demonstration purposes
                console.log('REST query results:');
                console.log(obj.d.results);
            },
            error: function (err) {
                alert(JSON.stringify(err));
            },
        });
    },
    createListItemWithREST: function () {
        var context;
        var factory;
        var appContextSite;
        var listName = "TEST"; // SharePoint list dependancy
        var listTitle = Utils.getRandomString();

        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);

        // metadata to update.
        var item = {
            "__metadata": { "type": Utils.getItemTypeForListName(listName) },
            "Title": listTitle,
        };

        var requestBody = JSON.stringify(item);
        var requestHeaders = {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": NWF$("#__REQUESTDIGEST").val(),
            "X-HTTP-Method": "PATCH",
            "content-type": "application/json;odata=verbose",
            "If-Match": "*"
        }

        executor.executeAsync({
            url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + listName + "')/items?@target='" + encodeURIComponent(hostweburl) + "'",
            method: "POST",
            contentType: "application/json;odata=verbose",
            headers: requestHeaders,
            body: requestBody,
            success: function () {
                console.log("update success.");
            },
            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[i].split('=');
            if (singleParam[0] == param) {
                return singleParam[1];
            }
        }
    },
    getItemTypeForListName: function (str) {
        return "SP.Data." + str.charAt(0).toUpperCase() + str.slice(1) + "ListItem";
    },
    getRandomString: function () {
        var text = "";
        var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

        for (var i = 0; i < 5; i++)
            text += possible.charAt(Math.floor(Math.random() * possible.length));

        return text;
    }
};

Any help would be greatly appreciated!

Thanks,

Patrick

Labels: (1)
0 Kudos
Reply
6 Replies
Automation Master
Automation Master

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

Hello again, just wanted to check back on this issue. Any ideas on the above?

Reply
Automation Master
Automation Master

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

‌ What's the best way for me to escalate a somewhat complex issue like this? I'd really like to get to the bottom of this one! Thank you sir.

0 Kudos
Reply
Not applicable

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

Did you ‌? If so, I can try to inquire what the status of the case is.

0 Kudos
Reply
Automation Master
Automation Master

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

Just submitted a ticket to get the ball rolling there. Thanks ‌.

Reply
tphan
Nintex Newbie

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

‌, did anything come out of this? I'm looking at trying to use the REST operations to update lists instead of workflow. I've gotten the same error from POST whereas GET is still working as intended.

Thanks!

0 Kudos
Reply
Automation Master
Automation Master

Re: REST updates no longer working – Nintex Forms for Office 365 (v. 1.2.3.0)

Unfortunately no. I've had a ticket open on it for 6 months that's been escalated a number of times but have yet to get an answer from the engineering team.

I was essentially told that this falls outside of Nintex's support despite documentation on the community claiming this operation should be possible.

0 Kudos
Reply