Forum Discussion

PrashantSetia's avatar
PrashantSetia
Occasional Contributor
6 years ago

Loop through REST header

Hello All,

 

I need to loop through header with various values in REST services. How could i do that. Thanks in advance.

1 Reply

  • So, if I unterstand this correctly you have a setup like this:

    Project
        - Test Suite
            - Test Case
                 - Test Step
                    - REST Request

    You can add a groovy script somewhere, in this example we add it directly after the REST request.

     

    Project
        - Test Suite
            - Test Case
                 - Test Step
                    - REST Request
                    - groovy script

    Then you can add a bit of code to loop through the header values:

    context.testCase.getTestStepByName("REST Request").getHttpRequest().getParams().each {
    	log.info it.key
    }
    

    Here I had the values address and sensor, the output generated the same values..