How to get id in responseHeaders location?

眉间皱痕 提交于 2019-12-11 06:30:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!