问题
For my POST request, in responseHeaders I get 1 < location: /users/123
I would like to print only the id > 123.
When I do * print responseHeaders['location'][0]
in my feature file, I get users/123
. How I can get only the id?
回答1:
This is not really a Karate question is it :P
Try this:
* def location = responseHeaders['location'][0]
* def userId = location.substring(location.lastIndexOf('/') + 1)
* print userId
That's right, all the power of JavaScript (or even Java via Java interop) is available to you in Karate !
来源:https://stackoverflow.com/questions/46359698/how-to-get-id-in-responseheaders-location