Home > Enterprise >  karate framework save response from 1 request and then use in another request
karate framework save response from 1 request and then use in another request

Time:06-24

In karate frame work is it possible to save response from 1 request and then use it in request body of another request?

Example: in Request 1 I send user name and user id in request body and in response I get user address.

In request 2 body, I want to use that address and validate house type.

Is it possible?

CodePudding user response:

Yes it is possible. The hello world example itself shows this.

See how in this example below also the response of the first request is used in the path of the second request. You can cut and paste this and try it:

* url 'https://httpbin.org'
* path 'anything'
* request {"myKey":"myValue"}
* method get
* status 200

* def myResult = response.json.myKey
* path 'anything/'   myResult
* method get
* status 200
  • Related