How to test REST API with Login Authentication
Hi, I am trying to test REST API. The login authentication has its own URI and it works when I test it. However, I have another URI but it requires the Login Authentication to execute first. So, what I did was I created a REST project, create a Resource for Login Authentication and another Resource for the other the URI. When I ran the TestRunner, it does not seem to authenticate well. Is this the way to tests or is there another way? Thanks1.7KViews0likes4CommentsUsing context parameter in Request Authorization
Hi, I am currently building a Test Case in which I use scripts to parse the response body of a few REST API Call Test Steps. 1. I create a user: POST /user/signup. 2. I log in with the created user: POST /user/login ( response body contains a JWT token that I want to use as Authorization in the following API Calls ) 3. I parse the token with the following script: import groovy.json.JsonSlurper responseContent = testRunner.testCase.getTestStepByName("POST User Login").getPropertyValue("response") jsonParser = new JsonSlurper().parseText(responseContent) context.JWTToken = jsonParser.token log.info ("Token in context: " + context.JWTToken) The token correctly logs in the log.info (line 5 of the script), so it is valid and stocked as a context variable. 4. I want to create a product: POST /products . This API Call needs a valid JWT to suceed, so I want to pass my stocked context.JWTToken as the value of the the Access Token. It doesn't work and I would gladly like to get some help on how to make it work. I also tried: ${context.JWTToken} ; context.JWTToken ; JWTToken ; ${=JWTToken} ; ${JWTToken} Thank youSolved3.8KViews1like2Comments