0

Using Karate i am making API calls sequentially. I need to store API request and response for this sequential flow of APIs in separate text files for each API call. Need to understand how can i achieve this.

I have tried logback which stores entire execution logs in a text file.

1 Answers1

0

Take a look at karate.prevRequest which will give you the "request". Now use some custom Java (or JS) code and write whatever you want to a file.

I think personally it is un-necessary because Karate's HTML report has all that you need. If someone is asking you to do this, please try convince that person that this exercise is a waste of time.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi Peter. We wanted directly print the HttpClient response to a txt file. 1 > POST https://api.obapi.bankofireland.com/oauth/as/token.oauth2 1 > Accept-Encoding: gzip,deflate 1 > Connection: Keep-Alive 14:41:30.753 [pool-1-thread-1] DEBUG com.intuit.karate - response time in milliseconds: 959 1 < 200 1 < Connection: keep-alive 1 < x-fapi-interaction-id: 824515e3-b850-4902-a0ad-ebb63fc9b58a 1 < x-frame-options: DENY 1 < x-xss-protection: 1; mode=block { "expires_in": 299 } – ruchira more Sep 20 '19 at 13:49
  • for those interested in other alternatives, please see: https://stackoverflow.com/a/59080128/143475 – Peter Thomas Feb 04 '20 at 16:12