Skip to main content

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Example job definitions

What is it?

This page provides sample Webservices Connector job definitions showing common capabilities of the connector. Each example covers the variables to define on the Global Values tab and the steps to define on the Steps tab.

For a reference to all the fields shown in these examples, see Defining jobs.

Choose an example

#ExampleWhat it demonstrates
1Token authentication (multi-step)Acquire a token, look up a property ID, update the property.
2Poll a long-running operationSubmit a schedule build and poll the build status.
3OAuth2 with x-www-form-urlencodedAcquire an OAuth2 token from Azure AD.
4Basic Mode authenticationSend a request with HTTP Basic auth.
5Use Environment VariablesPass an OpCon property containing a Windows path through the agent environment.
6Save a returned value into an OpCon propertyUse Property Update on Completion to write a response value back to OpCon.
7Windows Authentication (NTLM)Authenticate to IIS using NTLM.
8Client certificate authenticationAuthenticate using a PKCS12 keystore.
9File uploadUpload a file using multipart/form-data.
10SOAP WebservicesSubmit a SOAP envelope and extract a value from the response.
11Start and monitor a VisualCron job (RPA)Use the VisualCron REST API to launch and track a VisualCron job.
Reading these examples

Each step in an example shows only the fields you need to set. Fields not shown — such as Proxy Server and TLS — keep their defaults. The connector uses TLS automatically when the URL begins with https.

1. Token authentication (multi-step)

Goal: update the value of an OpCon global property using token authentication.

The OpCon REST API uses token authentication. The first step obtains a token, the second step looks up the property ID, and the third step updates the property value.

Variables (Global Values tab)

VariableValue
@UrlSERVER1:9010
@Useruser
@Password[[user_pwd]]
@GlobalPropertyPROPTEST

The password is held in an encrypted global property ([[user_pwd]]).

Step 1 — Acquire a token

FieldValue
FunctionPOST
URLhttps://@Url/api/tokens
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

Request body:

{
"id":null,
"user":
{
"id":-1,
"loginName":"@User",
"password":"@Password"
},
"tokenType":
{
"id":null,
"type":"User"
}
}

Response variable:

NameJSONPath
@Token$.id

$.id extracts the value of the first id attribute at the JSON root and stores it in @Token for use by later steps.

Step 2 — Look up the global property ID

FieldValue
FunctionGET
URLhttps://@Url/api/globalproperties?name=@GlobalProperty
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

Request header:

Attribute NameAttribute Value
AuthorizationToken @Token

The connector substitutes @Token with the value extracted in Step 1.

Response variable:

NameJSONPath
@Propertyid$[0].id

The response is an array of property definitions. $[0].id selects the id of the first array element.

Step 3 — Update the global property

FieldValue
FunctionPUT
URLhttps://@Url/api/globalproperties/@Propertyid
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

The @Propertyid extracted in Step 2 is substituted into the URL.

Request header:

Attribute NameAttribute Value
AuthorizationToken @Token

Request body:

{
"id":"@Propertyid",
"name":"@GlobalProperty",
"value":"wsrest 1234 test value from UNIX 2"
}

@Propertyid is also substituted in the body because the OpCon REST API expects the property ID in the payload when updating.

2. Poll a long-running operation

Goal: trigger an OpCon schedule build and poll the build status until it succeeds or fails.

Variables (Global Values tab)

VariableValue
@UrlSERVER1:9010
@Useruser
@Password[[user_pwd]]
@ScheduleNameSCHED001
@ScheduleDate[[$SCHEDULE DATE-YYYY-MM-DD]]
Date format

@ScheduleDate must be in yyyy-mm-dd format. Use a $SCHEDULE DATE property to supply this.

Step 1 — Acquire a token

Same as Step 1 of Example 1.

Step 2 — Submit the schedule build

FieldValue
FunctionPOST
URLhttps://@Url/api/schedulebuilds
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code201

Request header:

Attribute NameAttribute Value
AuthorizationToken @Token

Request body:

{
"schedules":[
{"id":null,"name":"@ScheduleName"}
],
"id":null,
"expiryTime":null,
"dates":[
"@ScheduleDate"
],
"logFile":null,
"overwrite":true,
"hold":true
}

Response variable:

NameJSONPath
@Buildid$.id

Step 3 — Poll the build status

FieldValue
FunctionGET
URLhttps://@Url/api/schedulebuilds/@Buildid
Request Content-Typeapplication/json
Response Content-Typeapplication/json

Request header:

Attribute NameAttribute Value
AuthorizationToken @Token

Step Completion (returned-data check + polling):

FieldValue
Attribute to Check$[0].message
Good Finishsuccess/Completed
Bad FinishFailed
Pollenabled
Delayseconds before the first check
Intervalseconds between subsequent checks
Max Time5 minutes
OutcomeConnector return code
Good Finish matched200
Bad Finish matched460
Max Time expired408

3. OAuth2 with x-www-form-urlencoded

Goal: acquire an OAuth2 access token from Azure Active Directory.

The body is sent as name=value pairs separated by an ampersand (&).

Variables (Global Values tab)

VariableValue
@Urllogin.microsoftonline.com
@Tenantid[[AZURE_TENANT_ID]]
@Clientid[[AZURE_CLIENT_ID]]
@Key[[AZURE_KEY]]
@Subscription[[AZURE_SUBSCRIPTION]]
caution

All OAuth2 credentials should be held in encrypted global properties.

Step 1 — Acquire an OAuth2 token

FieldValue
FunctionPOST
URLhttps://@Url/@Tenantid/oauth2/token
Request Content-Typeapplication/x-www-form-urlencoded
Response Content-Typeapplication/json
Completion Code200

Request body:

grant_type=client_credentials&client_id=@Clientid&client_secret=@Key&resource=https://management.azure.com/

Response variable:

NameJSONPath
@Token$.access_token

4. Basic Mode authentication

Goal: send a request authenticated with HTTP Basic.

The connector detects Authorization: Basic and Base64-encodes the @User:@Password string into the header automatically.

Variables (Global Values tab)

VariableValue
@Urleasyredmine.com
@UserUSER001
@Password[[USER001_PWD]]

Step 1 — Send the authenticated request

FieldValue
FunctionGET
URLhttps://@Url/issues/182.xml
Request Content-Typeapplication/xml
Response Content-Typeapplication/json
Completion Code200

Request header:

Attribute NameAttribute Value
AuthorizationBasic

5. Use Environment Variables

Goal: use a body file whose path comes from an OpCon schedule instance property containing Windows path separators.

OpCon resolves properties into the JSON job definition at run time without escaping backslashes — a value like c:\production\main would break JSON parsing. Passing the value as an Environment Variable bypasses the JSON definition entirely.

For background, see Operation > Environment Variables.

Variables (Global Values tab)

VariableValue
@UrlSERVER1:9010
@Useruser
@Password[[user_pwd]]

Environment Variables (Global Values tab)

VariableValue
@MAIN_PATH[[SI.MAIN_PATH]]

SI.MAIN_PATH is a schedule instance property containing the directory where the body file lives (for example, c:\production\main).

Step 1 — POST a body loaded from a file

FieldValue
FunctionPOST
URLhttps://@Url/api/tokens
Request Content-Typeapplication/json
Body sourceFile Name field
File Name@MAIN_PATH\wsfiles\login.json
Response Content-Typeapplication/json

File contents (login.json):

{
"id":null,
"user":
{
"id":-1,
"loginName":"@User",
"password":"@Password"
},
"tokenType":
{
"id":null,
"type":"User"
}
}

Response variable:

NameJSONPath
@Token$.id

6. Save a returned value into an OpCon property

Goal: capture a value from the response and persist it into an OpCon schedule instance property when the job completes successfully.

Property Update on Completion (Global Values tab)

Property pathSource variable
SI.Version.[[$SCHEDULE DATE-YYYY-MM-DD]].SCHED001@Version
caution
  • The dot (.) is used as a field separator in property paths. Schedule and job names must not contain a dot.
  • Date values must be in yyyy-mm-dd format. Use a $SCHEDULE DATE property to supply this value.

Step 1 — Read the OpCon REST API version

FieldValue
FunctionGET
URLhttps://@Url/api/version
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

Response variable:

NameJSONPath
@Version$.opConRestApiProductVersion

When the job completes successfully, the connector writes the value of @Version into the schedule instance property defined in Property Update on Completion.

7. Windows Authentication (NTLM)

Goal: authenticate to an IIS endpoint using Windows credentials.

Variables (Global Values tab)

VariableValue
@UrlOPCON01
@UserUSER001
@Password[[USER001_PWD]]
@DOMAINOPCON001

Step 1 — Send the authenticated request

FieldValue
FunctionGET
URLhttps://@Url/version
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

Request header:

Attribute NameAttribute Value
AuthorizationNTLM

The connector detects NTLM and uses @User, @Password, and @Domain to build the credentials.

8. Client certificate authentication

Goal: authenticate to a server that requires a client certificate.

Variables (Global Values tab)

VariableValue
@CertStorec:\wsconnector\store\badssl.pkcs12
@CertStorePwd[[BADSSL_PWD]]
@CertStoreTypePKCS12

For instructions on creating the keystore from a .p12 client key, see Operation > Create a keystore.

Step 1 — Send the authenticated request

FieldValue
FunctionGET
URLhttps://client.badssl.com
Request Content-Typeapplication/json
Response Content-Typeapplication/json
Completion Code200

Request header:

Attribute NameAttribute Value
AuthorizationCERT

The connector detects CERT and loads the certificate from the keystore named in @CertStore.

9. File upload

Goal: upload a file to a web server using multipart/form-data.

File location

The file must be present on the server where the connector is installed.

Step 1 — Upload the file

FieldValue
FunctionPOST
URLhttp://httpbin.org/post
Request Content-Typemultipart/form-data
Body sourceFile Name field
File Namefull path of the file to upload
Record terminationCRLF (Windows targets) or LF (Unix/Linux targets)
Response Content-Typeapplication/json
Completion Code200

To submit additional form fields alongside the file, enter them in the Message Body as name=value&name1=value1.

10. SOAP Webservices

Goal: submit a SOAP envelope to a SOAP web service and extract a value from the response.

A SOAP request requires:

SettingValue
FunctionPOST
Header attributeMessage-Type=SOAP
Request Content-Typetext/xml
Response Content-Typeapplication/xml
BodyThe complete SOAP envelope (soap12:Envelope)
Find the SOAP envelope shape

Retrieve the WSDL by opening the service URL with ?wsdl appended in a browser (for example, https://www.w3schools.com/xml/tempconvert.asmx?wsdl). The WSDL lists the supported endpoints.

Step 1 — Convert Celsius to Fahrenheit

FieldValue
FunctionPOST
URLhttps://www.w3schools.com/xml/tempconvert.asmx
Request Content-Typetext/xml
Response Content-Typeapplication/xml
Completion Code200

Request header:

Attribute NameAttribute Value
Message-TypeSOAP

Request body (SOAP envelope):

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CelsiusToFahrenheit xmlns="https://www.w3schools.com/xml/">
<Celsius>50</Celsius>
</CelsiusToFahrenheit>
</soap12:Body>
</soap12:Envelope>

Response variable:

NameXPath
@Fahrenheit//CelsiusToFahrenheitResponse/CelsiusToFahrenheitResult/text()

11. Start and monitor a VisualCron job (RPA)

Goal: use the VisualCron REST API to authenticate, start a job, monitor it to completion, and optionally retrieve a job variable value.

A VisualCron job is similar to an OpCon sub-schedule and contains one or more tasks. The connector monitors the job — not individual tasks — for completion.

VisualCron uses GET for everything

The VisualCron REST API uses GET for all requests. Job parameters are passed as query-string arguments.

Use Webservices variables to define the URL, user, password, and job name so the job is portable.

VariablePurpose
@UrlVisualCron REST API host.
@User, @PasswordVisualCron credentials used to authenticate.
@JobnameName of the VisualCron job to launch.
@VariablesOptional. VisualCron job variable values, formatted as varName1=value|varName2=value.

Step sequence

#PurposeURLResponse variable
1Authenticatehttp://@Url/VisualCron/json/logon?username=@User&password=@Password&expire=3600@Token from $.Token
2Look up job IDhttp://@Url/VisualCron/json/Job/GetByName?token=@Token&name=@Jobname@Jobid from $.Id
3Start the jobhttp://@Url/VisualCron/json/Job/Run?token=@Token&id=@Jobid&variables=@Variables (or omit the variables= parameter)
4Poll the job statushttp://@Url/VisualCron/json/Job/Get?token=@Token&id=@JobidCheck $.Stats.Status (Good Finish 1, Bad Finish 2)
5Read the exit codehttp://@Url/VisualCron/json/Job/Get?token=@Token&id=@JobidCheck $.Stats.ExitCode (Good Finish 0)
6(Optional) Read a job variablehttp://@Url/VisualCron/json/JobVariableValue/Get?token=@Token&jobId=@Jobid&id=jobvarnameUse TEXTSTRING

VisualCron status codes

The status returned in $.Stats.Status uses the following codes:

StatusMeaning
0Job is running.
1Job is waiting. In VisualCron, a job returns to the waiting state when it completes.
2Paused.

VisualCron exit codes

After completion, read the exit code from $.Stats.ExitCode:

Exit codeConnector return
0 (Good Finish)200
Any other value404

Reading a VisualCron job variable

VisualCron job variable values are returned as a plain text string, not JSON. Capture the result with a response variable whose value is TEXTSTRING. The connector then inserts the entire returned payload into the variable without parsing it.

FAQs

Where do I define variables that are reused across steps? On the Variables section of the Global Values tab. Variables are referenced by name (prefixed with @) in URLs, headers, and message bodies. Values from a previous step's response can be assigned to a variable on the Response Variable Management tab and used in later steps.

How is a token from an authentication step passed to later steps? Define a response variable (for example, @Token) with a JSONPath expression that extracts the token from the authentication response. Subsequent steps reference @Token in the Authorization header value (for example, Token @Token).

When should I use Environment Variables instead of Variables? When an OpCon property value contains characters (such as unescaped backslashes in Windows paths) that would break JSON parsing. Environment Variables are passed to the agent through the OS environment rather than through the JSON job definition.

How do I retrieve a VisualCron job variable value? Issue a GET request to http://@Url/VisualCron/json/JobVariableValue/Get?token=@Token&jobId=@Jobid&id=jobvarname. Because VisualCron returns a plain text string rather than JSON or XML, define a response variable with the value TEXTSTRING to capture the result.

What completion codes does the connector return for poll requests? The connector returns 200 (or the configured Completion Code) on a Good Finish, 460 on a Bad Finish, and 408 if the Max Time value expires before a Good Finish or Bad Finish is detected.

How do I upload a file? Select multipart/form-data as the Content-Type, enter the full file path in the File Name field of the Body tab, and select the record termination string (CRLF for Windows targets, LF for Unix/Linux targets). To submit additional form fields, add them in the Message Body as name=value&name1=value1.

Glossary

TermDefinition
Token authenticationAuthentication mode where credentials are exchanged for a short-lived token that is passed in the Authorization header on subsequent requests.
Basic authenticationAuthentication mode that Base64-encodes @User:@Password and passes it in the Authorization header.
NTLMWindows Authentication mode used for IIS endpoints. Requires @User, @Password, and @Domain variables.
OAuth2Token-based authentication mode that uses application/x-www-form-urlencoded and credentials such as client_id, client_secret, and tenant_id.
PollingConnector capability that re-issues a request on a configured interval until a Good Finish or Bad Finish is matched, or Max Time expires.
TEXTSTRINGA response variable value that tells the connector to capture the entire returned payload as a plain text string rather than parse it as JSON or XML.
multipart/form-dataA Content-Type used to upload a file. Requires a record termination selection (CRLF or LF) on the Body tab.
SOAP envelopeThe XML message body submitted to a SOAP web service. Requires Message-Type=SOAP in the request header and a Content-Type of text/xml.