Scenario outline examples from .txt file (Each line in the .txt file is a JSON)

Viewed 114

I want to send POST requests with the the request body (JSON ) from a .txt file. Each line in the .txt file is a JSON request and I want to send the request as is for each line.

Here is my feature file:

Scenario Outline: Read from txt * url blah blah Given request And header Content-Type = 'application/json' When method post Then status 201

Examples:
|Req|
|read('Requests.txt')|

Here is my sample .txt file

{"merch":"asf","name":"twin","currencyCode":"USD","amount":4000}
{"merch":"are","name":"pdf","currencyCode":"USD","amount":2500}

Could you please guide how I could accomplish this. I tried using .csv, but the entire JSON is not read in that case for each line. I am looking for a very simple way of sending the request one by one for each line in the .txt file.

1 Answers
Related