I’m designing automation scripts utilizing the REST APIs, RestAssured with Cucumber BDD framework. I’ve a number of APIs the place one API’s response is used as a parameter in one other API.
Right here is my function file:
Function: Create Order API
@Background:
State of affairs Define: Generate Entry token With Legitimate Particulars
Given Question param for request
| grant_type |
| client_credentials |
Given Fundamental Auth keys for request "" and ""
When Construct request for baseurl "PAYPAL_BASE_URI" and endpoint "ENDPOINT_GET_AUTH_KEY"
And Carry out "POST" request utilizing
Then standing code is 200
And response comprises "scope"
Examples:
| userName | key |
| AWnCb | EMAekuSA2f |
Now the response of the above API is as follows:
{
"scope": "https://uri.pppaypal.com/providers/invoicing https://uri.pppaypal.com/providers/purposes/webhooks",
"access_token": "ALs1szFnv2TJ19Zf3vq",
"token_type": "Bearer",
"app_id": "APP-284543T",
"expires_in": 311286,
"nonce": "2022-05-31T03:41:41ZWs9dpOQ"
}
Now I want this “access_token” as within the “Create Order API” Authorization parameter with Bearer. additionally i must cross “app_id” and “nonce” within the Create Order API. The “Create Order API” function file is beneath:
State of affairs: Confirm create order api utilizing legitimate auth
Given Generate request
And Construct request for baseurl "PAYPAL_BASE_URI" and endpoint "ENDPOINT_CREATE_ORDER_API"
And Set header values as
| Content material-Sort | Authorization | app_id | nonce |
| software/json | | | |
When Carry out "POST" request utilizing "FILE_PATH_ORDER_JSON"
Then standing code is 201
How can I get the values from the response of 1 API and the use that information within the subsequent API as payload or question param in the identical function file in order that I can use it wherever on this function file?