Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
4 years ago

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 ]

  • Mis3's avatar
    Mis3
    Frequent Contributor

    Anyone know why the square brackets?

    • AAB's avatar
      AAB
      Regular Contributor

      Hello Mis3 

      sorry for the late response. I just saw this now as I'm also looking on how to get rid of those brackets in groovy.

      But for your problem I would suggest to write a ticket to support from SmartBear. I think this is a bug.

       

      Kind regards

      AAB