简体   繁体   中英

How to pass post request parameters dynamically to get request in Karate

How do I pass a value of one API attribute to another API while automating in Karate ? I have a POST request which when submitted will generate an id in the response, and I pass that id dynamically to the upcoming GET request. I have already tried writing an Java method to read and write but it doesn't work.

Please forget about Java for a moment, Karate is very different !

For you I suggest you do this. Use the ZIP Release: https://github.com/intuit/karate/wiki/ZIP-Release

There is a ready-made test users.feature . See how line 12 extracts the first array element from the response and then we need to use the id key out of that element (which is a JSON object).

And then on line 14, it is used to make the next request.

在此处输入图片说明

Please spend some time reading the documentation , it is worth it !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM