1

I am running API execution using Scenario Outline and csv and want to edit header in the below format where i need to change the requestorid each and every time for the execution. If the headers uses below format and saved in .js and tried saving it in .json file:

"ID-HEADERS" :"{ 'requestorId': '1111', 'authMethod': 'basic'}"

And used below lines to edit the header which is not working:

function() {
         var fun = karate.read(headersFilePath + 'headers.js');
         var res = fun();
         res['ID-HEADERS.requestorId'] = requestorId;
         return res;
       }

1 Answers1

0

If you just need to set one header don't complicate it with JS:

Scenario Outline:
* url 'https://httpbin.org/anything'
* header foo = bar
* method get

Examples:
| bar |
| one |
| two |

Try it, and see the logs and HTML report. And read the documentation also.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248