The CreatorCon Call for Content is officially open! Get started here.

Run Python Script from Service Now Workflow

sachin_namjoshi
Kilo Patron
Kilo Patron

Hello,

I have developed python script to create users in DUO application for assigning them DUO token.

As per DUO documentation, we can consume DUO REST API only via python, perl or ruby clients. Service now can not consume DUO REST API directly due to security constraints.

I need to consume this python script from service now workflow.

What is the best way to call python script from service now platform?

Regards,

Sachin

 

15 REPLIES 15

Dave Spangler1
Kilo Contributor

Have a look at this web service integration tutorial using Python. I am not a Python guy so don't have much info beyond this but it appears this could be useful to you:

https://docs.servicenow.com/bundle/kingston-application-development/page/integrate/examples/concept/c_PythonWebServicesClientExamples.html?cshalt=yes

These examples talk about inbound integration to update service now record using python script.

I need examples of outbound integration to call python script from service now platform workflow.

 

Regards,

Sachin

TylerTeter
Kilo Guru

The only possible way to actually run a python script directly I can think of would be through Orchestration. And under orchestration, I can only think of two ways to do it.

You'll need to install Python on your MID servers that you intend to use.

Option 1:

This is probably the more OOB way to do it. You should be able to call it via a PowerShell activity using this syntax:

https://stackoverflow.com/questions/19676403/running-python-in-powershell

Learn more about creating powershell activities:

https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/orchestration-activity...


Option 2:

There is a way to run a system command from the ECC queue, and directly interact with the command terminal of the MID server.

You'd still use the same above command to run the python program.

 

Additionally you can interact directly to the ECC queue with a Run Script activity from the workflow, and insert stuff in there. You can use the GlideRecord API (less fancy) or use some of the undocumented Probe/ECC Queue APIs.

These answers are a little vague, and I can try and dig up more info for you, if you're interested.

Could you please explain more about option 2. We have a requirement in which we have to run the python code externally through the flow designer or workflow