Skip to main content

Nintex Workflow | parsing JSON responses from json-only web requests



Update 03/08/16:
Logic Apps has gone GA, and has undergone a major v2 change since this post was written. For the most part, the core actions remain the same but just renamed or work a little differently e.g. http listener (now known as "When an http request is received" + "Received") and conditions (now triggered via the add a condition" button instead of being configured inside the http action.)

It is worth noting that the BizTalk JSON Encoder API app can no longer be found in the marketplace. This is now a native function in Logic Apps. Though, I'll try to refresh this post with the how to do it in the version of Logic Apps that GA'd, I'm not sure when I will have to do it, so if you can't wait, I suggest looking at the xml function can be found here.

Update 07/08/16:
Steps for new Logic App UI that has GA have been added into the solution section below.

The problem


One of the things I have been working on lately in the Nintex Workflow world, is interacting with various software as a service based solutions within a workflow via REST based APIs.

One of the things we will find is that with the growing popularity of JSON, some REST based web services are no longer supporting returning responses of web requests in the XML format.

Workflows in SharePoint, has traditionally been focused around integrating with enterprise level SOAP based web services and Nintex is well catered in this area with it's Query XML Action. Unfortunately (as of the time this blog was written), there is currently no equivalent Query JSON Action within Nintex Workflow for On Premise.

The options


  1. Simple JSON structures: In most cases the JSON responses returned by APIs are simple and flat in structure.

  1. For this scenario, we can leverage (with relative ease) the regular expression capabilities within Nintex Workflow to parse the JSON string. A great example of this can be found from Vadim Tabakman's blog in Nintex Community: Uber price estimate UDA

  1. Complex JSON structures: In some cases JSON responses returned by API's can be nested and/ or contain arrays. Parsing responses of this nature using the regular expression can be more challenging.
    An example of a nested JSON Structure
    An example of a nested structure 



    If only there was a way to easily convert JSON into XML so that we can leverage the Query XML action...

    Well, the relatively recent introduction of the new Logic App and API App platfrom from Microsoft Azure looks to be a great timing. In the next section, we will look at how we can leverage Azure to easily create our own API to convert a JSON string into an XML string so that we can use the capabilities of Nintex's Query List action to retrieve information we need from a web service response.

The solution



Moving parts from Azure:
  1. Logic App: This is the platform that allows us to orchestrate and glues a combination of API Apps together.
  2. When an HTTP request is received: This API app triggers the start of the logic app (pictured above) when it receives a web request. Just add the action (there is no need to configure anything else). 
  3. Response: This API app is used to send back the converted XML string as a response to the application that sent the initial web request (e.g. Nintex Workflow). Ensure you configure the body field with "@xml(triggerBody())" which converts the content from the body of the HTTP request from JSON to XML. 
Using Azure Logic App JSON Encoder in Nintex Workflow
Nintex Workflow - Leveraging Azure to convert a JSON response into XML so that we can parse the information with the Query XML action

Moving parts from Nintex Workflow:


  1. Web Request (JSON Conversion): This action is used to call the API created in Azure Logic Apps (including passing the JSON string we want to convert into the XML)

    URL: Copy the URL that is generated in your "When an HTTP request is received" action.
    Request Type: POST
    Content Type: "application/json" (This is very important as it ensures the JSON string you pass to the Logic App is converted into a JSON object before the logic app tries to convert it into XML. Failure to do use this content type may result in an error).
    Authorization: No longer required

    Nintex Web Request Action
    This configurations shown in this screenshot is a little outdated. Please refer to the notes above for configuration.
  2. Query XML: This action is used to parse through an XML document to retrieve necessary information.
    Nintex Query XML Action

Next Steps

If you would like to try the azure logic apps and API apps out yourself, I would recommend reading the following blogs and articles to get started:
Do you also work with JSON based REST API in Nintex Workflow? Please feel free to share how you address this particular scenario in the comments below.

Popular posts from this blog

Access Web App | Filter a view by current user login (deprecated)

Update (April 1 2017): Microsoft has released an update that willl stop the creation of new apps starting June 2017, and shut down any remaining apps by April 2018. See more here

The problem One of the things I needed to do lately was see if a view within Access Web Apps can be configured to filter data that is related to the logged in user. e.g. as a user I want to be able to view a list of projects where I had been assigned as the project owner.

In SharePoint, this would have been quite easy to achieve as we can create a view and set the filter to {column name} is equal to [me].

Unfortunately Access Web Apps does not quite work this way:

No people picker control in Access Web Apps - this means we need to store and manage our own list of user data within a table in your Access Web App Database (or find a way to link a table with SharePoint's user profile or hidden user information list).Access Web Apps is a relational database - this means the approach to filtering a table view is…

Azure BizTalk Rules | A Getting Started Guide (deprecated)

Update December 12 2016:It looks like this service has disappeared from the azure portal and documentation that was previously available has also disappeared. 

This connector was developed for v1 of Logic Apps, and whilst Logic Apps has gone on to v2 + general availability, this connector was not one of the connectors that was supported by the current version of Logic Apps. 

I don't know if there is any plans to bring this connector back in the future, but if I see any updates, then I will update this post. 

One of the things I've been playing around with lately is the Azure BizTalk Rules API App from Azure (currently in public preview). BizTalk Rules has been around since BizTalk Server 2004, however the server offering for BizTalk required a large upfront investment in terms of cost as well as skills required to effectively leverage the tool.

The introduction of several BizTalk capabilities as a PaaS (Platform as a Service) offering in Azure is intended to make the capability …