mkleyn
October 22, 2019, 2:23pm
1
Hi All,
I’m new to the API testing category.
I’ve setup an Object Repositry for API via the following steps…
Right Click on Object Reposity
From the Option Menu >> Click on Import from Swagger
Typed in URL
Click OK
Currently, for every API Call I need to change the Authorization Token manually and it’s very frustrating.
Is there a way of to pick up the token automatically or set it in a data file?
Any help will be appreciated.
Thanks in advance.
sang
October 23, 2019, 10:51am
2
Hi mkleyn
Instead of using the hard code value, you can extract the Token from login API and assign it to another API header.
Hi Julian_Wladyczynski
Please retry by following this step:
1. Assigned access_token value to the GlobalVariable
response = WS.sendRequest(findTestObject('Employees/Login backoffice and get access token'))
WS.verifyResponseStatusCode(response, 200)
JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(response.getResponseText())
String access_token = parsedJson.access_token
GlobalVariable.Token = access_token
2. On the GET request, set the Variable as below.
[38%20PM…