Vadim Tabakman

Python to REST Nintex Workflow Cloud External

Although this post is specifically about the Raspberry Pi, I'm putting it in here, because this is going to be my start into writing some Python code to make a REST call.  Now it doesn't haven't to be Nintex Workflow Cloud, but since I do a lot of work around Nintex, this was the easiest thing for me to do.  Since I didn't have to go and build a REST service.  Instead, I build a workflow in Nintex Workflow Cloud that had an external start (REST end point).

I also wanted to see if I could write the Python script in the simplest possible way so that it's easy for everyone to understand.

Nintex Workflow Cloud

I know some of you may not know what Nintex or Nintex Workflow Cloud is.  Check it out.  It's quite amazing in letting you automate business processes with an easy to use drag and drop designer.  In this example, I created a simple workflow and configured it have an External Start with two parameters.

This is what the External Start settings look like :

Notice the two parameters, EventName and EventAmount.  These are going to be two JSON parameters we will be able to set from the Python script.

Next, we have a simple Send an Email action:

Finally, once you publish this workflow, you get all the REST information you need to then plug into the Python script.

 

Here are the minimum requirements I had.

  • REST Url
  • JSON data (payload)
  • Headers

# This is what the Python looks like.

import requests

url = 'https://........'

data = '{\

   "startData": {\

      "se_event_amount1": 20.4,\

      "se_event_name1": "Intruder alert"\

   },\

   "options": {\

      "callbackUrl": ""\

   }\

}'

headers = {'content-type': 'application/json'}

response = requests.post(url, data=data, headers=header)

print response.text

Now I saved this file as "nwcStart.py" and I was able to easily run this to make sure it works, using "python nwcStart.py".

Conclusion

This is just the beginning.  I wanted to see how easy it was to make a REST call from Python, since the aim will be for this type of script to be run when a sensor on the Raspberry Pi, senses something we are interested in.

I hope this helps.  If you have any questions, let me know.

Posted by Vadim Tabakman Wednesday, January 4, 2017 10:56:00 AM Categories: Nintex Nintex Workflow Cloud Python Raspberry PI REST

Comments

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register