How to upload a Web Services Before Operation Rule

Hello,

Looking for some help on how to perform the upload of the rule:

Following this example to create a web service before operation rule:

https://documentation.sailpoint.com/connectors/webservices/help/integrating_webservices/beforeoperat…

But the info on how to post the rule in the API call is not clear: create-connector-rule | SailPoint Developer Community

Specifically: how to code the body in the post request? What would the values be for “signature” and how does the “sourceCode”/“script” need to be encoded considering it’s java code enclosed in xml?

Hi Mario,

I would recommend installing the following extension in VS Code: IdentityNow Extensions for Visual Studio Code. This will let you more easily edit your source without needing to use Postman for these operations.
Once you’ve connected your tenant, you can create a new rule and can select the Web Service before operation rule:



You can leverage the samples from the post you linked to get started on the rule. If you right click this rule in VS Code, you can edit the script in standard java, rather than needing to translate it and put it in sourceCode/script.
To then link it back to a specific operation, you can go into the source in VS Code, and add the following tag into each HTTP operation you want the rule to run on:
"beforeRule": "<insert rule name>"

Hope this helps!

Thanks @margocbain !
I actually already have the VSCode extention but don’t use it much :slight_smile:

So when I create the “Before oper rule for web services” and try to save the Java code/blob within double quotes in the source tag,

it throws a parse error. The java class is 60 lines. I just copy/pasted it between the double quotes of the script tag…Does the code need to be reformatted/escaped?

Right click on the rule on the nav panel, edit script.

Perfect - that worked :slight_smile:

So just curious - if doing this via the API, how would the escape codes “\r\r\t”, etc. be created?

If by the API, you’d need to get the script escaped yourself. I typically would just use a find and replace to replace any newline with \n, etc.

1 Like

There is also a VSCode plugin called “JSON Escaper” that will escape or unescape whatever is highlighted instead of having to do a find/replace. I’ve used this for years and it really helps with rule script formatting (mainly before the ISC VSCode extension had the right click option). Once installed, you can highlight the code you want to (un)esapce, hit CTRL+Shift+P, and selece “Unescape JSON String” or “Escape JSON String” to format the script correctly.

2 Likes

If you’re calling the APIs say, via the PS SDK, there’s the Initialize-V2024SourceCode and Initalize-V2024ConnectorRuleCreateRequest.

That escapes the newlines for you.

1 Like

Great thanks!
Not a big fan of VSCode (prefer Eclipse) but I’m starting to get used to it

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.