If-None-Match header in karate mock

Viewed 32

I want to create a mock with karate to act on If-None-Match header. I tried to do what is shown here

Scenario: pathMatches('/path') && methodIs('get') && karate.get('requestHeaders.If-None-Match[0]') == '1'
   * def responseStatus = 304
   * def responseHeaders = { 'ETag': '1' }

It is not working. It is ignoring the karate.get part, and using the scenario defined after (the same one without headers):

Scenario: pathMatches('/path') && methodIs('get')
...

What am I doing wrong here?

1 Answers

Do it like this. I was able to get a response match.

Scenario: pathMatches('/path') && methodIs('get') && headerContains('If-None-Match', '1')
* def responseStatus = 200
* def responseHeaders = {'Etag':'1' }
Related