Invoke Web Service

<< Click to Display Table of Contents >>

Navigation:  Custom Actions > Variables > How to set dynamic values for variables >

Invoke Web Service

Web service call could return simple text or xml text or JSON text as output. We can store either of these output values as text values in variables or we can use functions like $xpath() or $jsonpath() functions to extract the required values and store them in the variables for later use.

 

If we use $xpath() function that returns array of objects then we can use the variable that stores this function return value and run for this variable to create multiple items. If the function returns single text value for the given xpath expression, then we can use this variable only in column mappings.

 

Example Web Service Call Result:

 

<Cities>

 <City id="1">Hyd</City>

 <City id="2">Bng</City>

 <City id="3">Delhi</City>

</Cities>

 

Sample Usage of Result:

 

Expression 1: $xpath(WebServiceActionName##Value,/Cities)

 

Output (Array of Objects):

Output1: [Cities: "<City id="1">Hyd</City><City id="2">Bng</City><City id="3">Delhi</City>"]

Output2: <City id="1">Hyd</City>

 <City id="2">Bng</City>

 <City id="3">Delhi</City>

 

Please note that $xpath() function internally contains two different output values as showed in above example. In this example, Output 1 is JSON object and it will be used in “Run for” in Create item Action. Output 2 is simple text and will be used in column mappings.

 

Expression 2: $xpath(WebServiceActionName##Value,/Cities/City[1])

 

Output (Simple Text):

Output1: {id: 1, City: Hyd}

Output2: Hyd

 

Similarly, if we use $jsonpath() function that returns multiple objects then we can use the variable that stores this function return value and run for this variable to create multiple items. If the function returns simple text then we can use this only in column mappings.

Refer $xpath() and $jsonpath() functions for more details.

 

Using the “Define Variable Mappings” section in the Invoke Web Service action settings page, we can assign values to variables (See screenshots below).

 

CUSTOM~1_img6

 

CUSTOM~1_img7

 

Variable value Supports following types

Literal/Custom values

Another field values (Place holders of current item and query list item actions that are executed before this web service action are supported)

Functions

 

Syntax for invoke web service action result value: Invoke web service action title##Value