3

This is a followup from a previous question I asked Using response data from one scenario to another

I am looking to take information from a response in one url, then use it in a second url for another assertion.

Something like this:

Scenario: Search for asset
Given url "https://foo.bar.buzz"
When method get
Then status 200
* def responseItem = $.items[0].id // variable initialized from the response
Given url "https://foo.bar.buzz/" + responseItem + "/metadata"
// making request payload
When method put.....

Right now when I run this, it gets hung up on the second Given statement.

Any thoughts on how to resolve this?

kmancusi
  • 591
  • 3
  • 20
  • "gets hung up" is a terrible description of a problem. try harder please. if `responseItem` is a valid string it should work – Peter Thomas May 01 '19 at 14:09
  • I made a change to the request method (now a GET). Instead of completely stopping, now it is telling me the request is unauthorized (an improvement). But it's confusing because I have my header data defined in my `Background`, and I'm within the same `Scenario`. Shouldn't the same auth be applicable for my second request? – kmancusi May 01 '19 at 14:46
  • totally depends on what you have done in the `Background`. hope someone else has the patience to help you - and this is the only advice I have left to offer: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas May 01 '19 at 14:48
  • I figured out what I needed to do; but it was unexpected. I have `* def headerData = { Authorization: Bearer foo/token }` in the `Background`. I had to add `And headers headerData` _after_ making my second `Given url` statement in order to get it to work – kmancusi May 01 '19 at 14:56
  • 1
    it would not be unexpected if you read the docs: https://github.com/intuit/karate#header – Peter Thomas May 01 '19 at 14:57

1 Answers1

1

As you probably figured out, the "Karate HTML report" will show you the request/response and headers, as long as you put DEBUG log level in your log4j config, and that will answer your question.

djangofan
  • 28,471
  • 61
  • 196
  • 289