Here Data transfer from Kwizbot via send_request we figured out how to send a request using send_request
send a request, now let's look at how to process the response.
We will use two services as a test API
This manual covers the following cases:
Let's make this action configuration
{
"url": "<http://worldclockapi.com/api/json/est/now>",
"method": "GET",
"response_mapping": {
"dayOfTheWeek": "today"
}
}
And this script configuration. What came before and what will happen after the request is not very important to us, our task is to display what day of the week is today in the placeholder today.
The mapping
parametr is responsible for which placeholder will be written to which parameter from the response. Everything is pretty clear here: the dayOfTheWeek
parameter after the response will be available with the {{today}}
placeholder.
Let's move on to getting the exchange rate. Let's make the following action configuration:
{
"url": "<https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=5>",
"method": "GET",
"response_mapping": {
"list_obj": {
"text": "{{ccy}}/{{base_ccy}}",
"value": "{{buy}}"
}
},
"save_mapped_list_obj": "currency_mapped_obj"
}
We need this script configuration:
The "list" block must be configured like this