Studio Creatio
PDF
This documentation is valid for Creatio version 7.16.0. We recommend using the newest version of Creatio documentation.

Setting up the parsing of the web service response parameters

As a result of calling a web service method, a certain response (a JSON object, which is basically a structured text) will be returned. To use data from that response, you need to set up parsing of the web service response parameters, i.e., which part of the returned code represents the data that was the goal of this web service integration.

EXAMPLE

Calling the “latest” method returns the requested information in a form of code string (open the link in your browser to view the actual response code). To process the web service response, set up how Creatio should parse the received code by configuring the response parameters.

The response comes in the form of values for the following three parameters:

  • base” – base currency, in relation to which the rates are calculated, for example:

   "base":"EUR"

  • date” – the date when these exchange rates were valid, for example:

   "date":"2018-02-19"

  • rates” – exchange rates of a set number of currencies (each represented as a separate nested parameter) in relation to the base currency, for example:

   "rates":{"AUD":1.5676,"BGN":1.9558,..."ZAR":14.461}

The simplest way to implement this is to parse only exchange rates for the needed currencies. Each exchange rate can be parsed as a separate parameter. In this example we will also parse the “base” and “date” parameters.

How to add the response parameters via Quick setup option

If you have the server response in JSON form, you can add the response parameters automatically by clicking the [Quick setup] button.

1.Click the [Quick setup] button and select the [Example in JSON] option in the “From response example” section (Fig. 1):

Fig. 1 the [Example in JSON] action for the response example

scr_web_service_response_json.png 

2.In the opened window, paste the JSON code of the server response (it will be displayed in your browser if you try to open a call web service URL) and click the [Next] button (Fig. 2):

Fig. 2 Response in JSON code

scr_web_service_json_code.png 

3.In the opened parameters list, select necessary parameters to add to the response and click the [Save] button (Fig. 3):

Fig. 3 List of parameters from JSON example

scr_web_service_response_parameters.png 

As a result, selected parameters will be added as response parameters. You can modify the settings of parameters (for example, change the data type of the currency rate to “decimal”) to adjust them for further using in the [Call web service] business process element.

How to add the response parameters manually

To add response parameters manually, click the [Add parameter] button on the [Response parameters] tab and populate their values.

1.Add “Base currency” parameter, which will indicate the base currency for the received exchange rates. Specify the parameter type as the “Body parameter” and the “Text” data type. The “Path to element “JSONPath” should contain the JSON syntax. JSONpath “$.base” gets the value of the “base” parameter (e.g., "base":"EUR") in the web service response, in this case — “EUR”. (Fig. 4):

Fig. 4 “Base currency” query parameter settings

scr_web_service_add_method_response_parameter_base_currency.png 

2.Add “Date” parameter, which will indicate the validity date for the received exchange rates. Specify the “Date” for the parameter (Fig. 5):

Fig. 5 Date response parameter settings

scr_web_service_add_method_response_parameter_date.png 

Note

JSONpath “$.date” gets the value of the “date” parameter (e.g., "date":: "2018-02-16") in the service response, which in the current case is “2018-02-16”.

Case

As part of this case, we will be parsing each exchange rate as a separate parameter. For example, Australian dollar rate will be passed as a value of the “RatesAUD” parameter.

3.Add parameters for parsing the exchange rate values. Specify the “Decimal” data type (Fig. 6):

Fig. 6 RatesAUD response parameter settings

scr_web_service_add_method_request_parameter_rate_aud.png 

Note

JSONpath “$.rates.AUD” gets the value of the “AUD” parameter, which is nested in another parameter, “rates” (i.e.: "rates":{"AUD":1.5676}) in the service response. In this case, the value of the $.rates.AUD is 1.5676.

4.Set up response parameters for parsing all needed currencies (Fig. 7).

Fig. 7 Setting up response parameters of a web service

scr_web_service_add_method_response_parameter.png 

Did you find this information useful?

How can we improve it?