Hi,
Up to now, I have never use Katalon to test REST services. I have an application that uses OAUTH2 and the token goes in the header.
In SoapUI, I paste the request address plus parameters of the login, and I make of this my first request,
Then I paste the request address to do a search and paste the bearer token in the header, and this is my second request, and then I create the test:
step 1: the login request
step 2: a groovy script to set a variable of my choice at test level (let’s call it auth_code)
step 3: the search request, where in the header I pass the test case variable auth_code
In Katalon, I can see lots of fields and tabs, but nowhere is explained in detail what are they for.
Up to now, this is what I have done:
In the object repository, I have created 2 Restful request:
1 - login
2 - search
In the login request, I have set up the following values:
Authorization tab:
Type: OAuth 2.0
Grant type: Passord DCredentials
then I clicked in the “Update to HTTP Header” button
HTTP body tab:
I chose JSON and passed on the login and password (copied and pasted from the Chrome tools network request):
{“login”: “myuser”, “password”: “mypassword”}
This works very well, but that’s it:
‘Get response’
def response = WS.sendRequest(findTestObject(‘Object Repository/Rest requests/login’))‘Verify response status 200’
WS.verifyResponseStatusCode(response, 200)‘get bearer token’
def auth_code = response.getHeaderFields().get(“Authorization”)
1- How can I pass the variable Authorization to the next request?
2- Is it possible to something at request level (in the object repository) to set/get the authorization header?
Thanks in advance