Karate: Not able to pass header value extracted from one api response into the request header of another api

Viewed 34

Here I'm storing the value of Etag into variable etag, here the values is printed correctly:

Given path '/price/v4/quote/',quoteId,'/products'

And request requestPayload

When method POST

  • print 'headers:', karate.prevRequest.headers

Then status 200

And def etag = responseHeaders['ETag']

  • print etag [print] ["3"]

Now I'm passing it to the request header of another api:

* header If-Match = etag
Given path '/price/v4/quote/',quoteId,'/accept'
And request requestPayload
When method PUT
* print 'headers:', karate.prevRequest.headers
Then status 200
* print karate.pretty(response)

But I'm getting following error as the value of etag header comes with regex:

Got invalid quoteVersion for quote 'b25f50bc-0479-4390-b4fe-0620fc6c6139'. quoteVersion '[\"3\"]', actualVersion '3'"}
1 Answers
Related