Given I set the header "Header-Name" to "Header-Value"

This step definition is used to set HTTP headers for API requests in your tests. It provides a flexible way to define headers like Content-Type, Authorization, or Accept, which are often required when calling APIs.

Given (?:I set the header|the header) "([^"]*)" (?:to|is) "([^"]*)"$

This adds or updates the specified request header.

 

Example #1: Given I set the header "Content-Type" to "application/json"
Example #2: Given I set the header "Authorization" to "Bearer token123"
Example #3: Given the header "Accept" is "application/json"