Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
4 years ago

How to output the HTTP response to a log file

This is another API I am working with. I use the following to output the results to a log file. def header = tStep.getTestRequest().response.responseHeaders log.info " Seq="+i+" "+"="+data[1]+"|Re...
  • Mis3's avatar
    Mis3
    4 years ago

    It is working now after some trial-and-errors.

    I replaced the def statement by String statement and the lines below did remove the square brackets.  

     

    String MESSAGE_TAS = tStep.getTestRequest().response.responseHeaders.'#status#'
    MESSAGE_TAS = MESSAGE_TAS.replaceAll("[\\[\\](){}]","")    // remove square brackets
    log.info " Seq="+i+" "+data[1]+",TAS-Put Result: "+MESSAGE_TAS

     

    Log info= Fri Sep 17 11:10:18 EDT 2021:INFO: Seq=5 14313140097,TAS-Put Result: HTTP/1.1 204