Tuesday, January 10, 2017

Executing Custom Scripts with REST

This is a quick one...

As you may know, GJG (aka Great John Goodwin) has introduced FDMEE and REST in his blog:
So I'm going to steal a bit of his hard work :-)

In my review of PSU210 I went through executing a custom script from command line.

The formula is then easy, My post + GJG's post = Executing Custom Script with REST

We already saw that a custom script is actually treated as a report. Therefore syntax to execute the custom script with REST does not differ so much from the one John showed. The only difference is that reportFormatType is SCRIPT rather than REPORT.

BTW, I'm using RESTClient in Firefox. I'm not going to cover basics to add header with authentication and json content, etc. You can visit John's blog for that.

Also be aware this is only possible in FDMEE on-premise as Data Management in the Cloud does not support scripting yet.

Executing Custom Script without Parameters
We have three mandatory keys in the request body:
  • jobType = REPORT
  • jobName = this is the script name when you registered (not the py file)
  • reportFormatType = SCRIPT
After calling the REST resource to run jobs, we get both status and job id. We can then easily get status to see if it's completed or error was raised:
As you can see, processType is now COMM_EXECUTE_CUSTOM_SCRIPT.

If you navigate to FDMEE, process details page will show the script being successfully executed:

Executing Custom Script with Parameters
If your script uses parameters, then you need to add them to the json body:
Status can be checked in the same way as before:
And finally, process details will show execution:

And that's all I wanted to show. With the new PSU you can now execute custom scripts from external systems in a very easy way.

Thanks again to John for introducing FDMEE and REST.


No comments:

Post a Comment

Thanks for feedback!