Hi All,
We are using SharePoint Online with Nintex Forms O365. We are trying to query a SharePoint List from the host web from Nintex Forms O365 but is facing difficulty.
We are using REST API POST query because of a calculated field. Currently, we are facing difficulty using it because Nintex Forms is located in a separate App Web, resulting in an Access Denied (403) error when trying to access the Host Web URL.
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl")); var viewXml = "<Query><Where><And><And><Geq><FieldRef Name='EndDate_Adjusted' /><Value Type='DateTime'>" + str_startdate + "</Value></Geq><Leq><FieldRef Name='StartDate_Adjusted' /><Value Type='DateTime'>" + str_enddate + "</Value></Leq></And><Eq><FieldRef Name='Workflow_x0020_Status' /><Value Type='Text'>Blocked</Value></Eq></And></Where></Query>"; var queryPayload = { 'query': { '__metadata': { 'type': 'SP.CamlQuery' }, 'ViewXml': viewXml } }; var url = appweburl + "/_api/SP.AppContextSite(@target)/web/lists/GetByTitle('Booking Requests')/getitems?@target='" + hostweburl + "'"; var executor = new SP.RequestExecutor(appweburl); executor.executeAsync( { url: url, method: "POST", body: JSON.stringify(queryPayload), headers: { "Accept": "application/json; odata=verbose", "content-type": "application/json; odata=verbose", "X-RequestDigest": NWF$("#__REQUESTDIGEST").val() }, success: function (data) { var jsonobj = JSON.parse(data.body); var results = jsonobj.d.results; for (var i = 0; i < results.length; i++){ blocked.push({ID: resultsui].ID}); } deferred.resolve(Boolean(valid)); }, error: function (data) { console.error(data); deferred.reject(Boolean(valid)); } } );
We cannot use GET request because EndDate_Adjusted and StartDate_Adjusted are calculated fields, which $filter does not support.
We cannot get / fill-in the correct RequestDigest because querying /api/_contextinfo would also need a POST query, which results in Access Denied as well.
What are the options that we can use / do in order to use REST API POST query?
Thank you