Mis3
4 years agoFrequent Contributor
Square Bracket added by Groovy when extracting part of the API header
Somehow Groovy would tag on the square brackets when I retrieved part of the header. I can certainly remove the square brackets by string manipulations but I like to understand why the square brackets are added.
Please refer to 2 examples below:
Example-1 (no square bracket added by Groovy))
String MESSAGE1 = tStep.getTestRequest().response.responseHeaders
log.info " Seq="+i+" "+MESSAGE1
Display: Fri Sep 17 15:50:55 EDT 2021:INFO: Seq=0 #status# : HTTP/1.1 204 Date : Fri, 17 Sep 2021 19:50:55 GMT
Exmaple-2: (square brackets added by Groovy)
MESSAGE1 = tStep.getTestRequest().response.responseHeaders.'#status#'
log.info = log.info MESSAGE1
Display: Fri Sep 17 15:50:55 EDT 2021:INFO: Seq=0 [HTTP/1.1 204 ]