Query list from another SharePoint Online subsite using Rest API and Nintex workflows

This Nintex tutorial, we will explore how to query/filter the SharePoint online list from another SharePoint Online subsite using REST API.

There are a lot of ways to query lists from another SharePoint online. This article is solely for the purpose of guiding you on how to solve permission issues when querying list from another SharePoint subsite.

We will use Nintex Workflow Call HTTP Web Service action to call the REST API to filter the list from another SharePoint subsite.

Permissions

The workflow app needs to be given full control at the SharePoint site collection. The app permissions for workflow can be configured by following the steps below (refer to https://msdn.microsoft.com/en-us/library/office/jj822159(v=office.15).aspx for more info):

To avoid Unauthorized Issues – you will need to add the app permissions at both the site and subsite levels.

First, you need to enable the “Workflows can use app permissions” feature at the site you are running the HTTP web service call workflow on.

To allow workflow to use app permissions

  1. Click the Settings icon at the top of the page (Gear cog icon).
  2. Go to Site Settings, Under the Site Actions section, select Manage site features.
  3. Locate the feature called ‘Workflows can use app permissions’, as shown in the screenshot below, and then click Activate.
Query list from another SharePoint Online subsite nintex

Next, we need to grant full control to the workflow app on the subsite you are running the web service call against.

To grant full control permission to a workflow

Navigate again to the Site Settings page on the site you are running the workflow from. Under the Users and Permissions section, select Site app permissions.

On this page, the app permissions will be displayed for all apps on your site. Copy the client section of the App Identifier for Workflow. This is the identifier between the last “|” and the “@” sign
Note down the workflow app id which is between i:0i.t|ms.sp.ext| and @

Query list from another SharePoint Online subsite using Rest API

Then navigate to the ‘Grant permission to an app’ page for the site you are trying to run the web service call against. This must be manually navigated  by typing the following URL: http://YourSite/_layouts/15/appinv.aspx

This will take you to a page that looks similar to this, follow the numerical point, as shown in the below screenshot.

Query list from another SharePoint Online subsite using Rest API and Nintex workflows

Paste the workflow App Id that you copied in step three and click Lookup. This will fill the Title, App Domain, and Redirect URL fields automatically.

In the Permissions Request field, paste the following XML:

<AppPermissionRequests>
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />
</AppPermissionRequests>

*(note this XML is literal and does not need to be modified in any way)

Click Create.

You will then be taken to a page where you are asked to trust the Workflow app. Click Trust It.

Query list from another SharePoint Online subsite using Rest API and Nintex workflows

Sharepoint Online Site_B we add the Employee No then apply query on Sharepoint Online Site_A to get the employee Title based on Employee No using Nintex workflow.

The logic of the Nintex Workflow was built using the following steps and to configure Call HTTP Web Service Action to calling REST API

  1. Sharepoint Online Site_A – the SharePoint online which contains the source list that we want to query.
  2. Sharepoint Online Site_B – the SharePoint online where the Nintex Workflow will be deployed.

Follow the below steps to create a new Nintex Workflow against a custom list when items are created using the Nintex Workflow Designer.

Nintex Workflow Call HTTP Web Service action

Declared Variables

Add key pair values as described in the table below

 Name Type Type
 Accept Text application/json;odata=verbose
 Content-Type Text application/json;odata=verbose

Build the Dictionary Variables

Use action “Build Dictionary” to build Dictionary RequestHeaders. We need to create headers for Accept and Content Type. To specify JSON as the format we’ll be sending the request and the format in which we want to get the response.

Build Dictionary variable nintex workflow

Create the Web Service Call

Drag and drop the Call HTTP Web Service action and use the variables we’ve set up for the different parameters of the action. Make sure you choose GET as the HTTP method of your request. Your action should look like this:

  • Address: {Sharepoint Site A – Url}/_api/web/lists/getbytitle(’employee’)/items?$filter=EmpNo eq ‘{Current Item:Title}’
  • Request Type: Select HTTP Get Option
  • Request Headers: build Dictionary RequestHeaders
  • Response Content: build Dictionary RequestContent
  • Response Status Code: Text Variable result
Nintex Workflow Call HTTP Web Service action
Nintex Workflow Call HTTP Web Service action rest api call

Get an Item from a Dictionary

Call HTTP Web Service action in nintex workflow

Drag and drop the Get an Item from a Dictionary action from the left toolbox.

Now let’s configure it. When you double click on the action the following screen Appear. Variable “ResponseContent” as Collection (Dictionary). From the “ResponseContent”, Now, let us get the “Title” value in TitleName variable.

Call HTTP Web Service action in nintex workflow office 365

Final Structure of Nintex workflow Action

how to call Call HTTP Web Service action in nintex workflow

Sharepoint Online Site_A: Using Nintex workflow trigger the query filter on this site in Employee list of EmpNo Column.

query list action in nintex workflow

Sharepoint Online Site_B: In this site we create Nintex Workflow and filter the Sharepoint Online Site_A site Employee list filter by EmpNo =103. The workflow triggers on item created.

nintex workflow query list for each

Output

The item level workflow history is in the below screen

nintex office 365 query list example

When using the “Call HTTP Web Service” action on a subsite you receive the following error:

Unauthorized – {“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.”}}}

To resolve this issue follow the Permission steps we explored.

You may like following Nintex tutorials:

This Nintex tutorial, we learned how to query list from another SharePoint Online sub site using Rest API and Nintex workflows for Office 365.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>