Testing / Karate Framework Interview questions
What is the header keyword used for in Karate?
header sets a single HTTP header on the request about to be made, commonly used for things like Authorization, Content-Type, or any custom header a particular API expects.
Given url 'https://api.example.com/users' And header Authorization = 'Bearer ' + authToken And header Content-Type = 'application/json' When method get Then status 200
For setting several headers at once, or headers that should apply to every request in a scenario or feature, configure headers = { ... } is usually the better fit, since it accepts a full JSON object of headers in one call rather than one header line per header.
More Related questions...