Script module allows you to set a Javascript variables in the probe request and the same can be used in other request fields like URI, HTTP method, Request body & headers.
Variables which are set in the first probe step can be used in the following steps.
How to add script variables
(refer number pointers in the above image)
Usage of script variables
(refer number pointers in the above image)
Example:
Declare variables:
var keyString = 'name' + ':' + '123';
var encodedValue = btoa(keyString);
Usage in request URI:
http://testorama-test.apigee.net/httpbin?name=${script.encodedValue}
This is really cool. I was on a webinar with AWS, and I asked them what they thought about Apigee Test.
His reply is that combining Apigee Test, mobile apm, Apigee Edge's analytics, and AWS Cloudwatch makes a killer combo for devops.
What is the recommended way to request a token before call an api?
You can make the request token call in the first step and then store the token in the extract variable.
In the second step you can use the extracted variable to call an API.
In case if you aren't aware how to use extract variables, below article guide you
https://community.apigee.com/articles/7934/extract-variables-in-api-monitoring-apihealth.html
How to get extract variable in script code?
I have written below code:
var consumerid=${ConsumerID};
var region=consumerid.substring(0,3);
where ${ConsumerID} is extracted in previous step of test case.
But I am getting error "Script execution in the request flow failed with the following error : ReferenceError:***consumeridvalue(contentHiddhenForsecurity)*** is not defined"
Using test cases to create probes
Apigee Test (earlier called API Health) - A Monitoring tool for your APIs
New UI and Conceptual Changes in Apigee Test
APIs to interact with Apigee Test
Apigee Test (earlier called API Health) Probe responses are limited to 1MB
Apigee Test (earlier called API Health) Outage on 2nd July
Apigee Test (earlier called API Health) documentation
PagerDuty support in apigee Test