Forum Discussion

sabereshcp's avatar
sabereshcp
Contributor
14 years ago

How to get the parameter names in a REST Request

Hi,

I wanted to know is there any way to get the number of parametres and their name in an REST Request.
If it can be retrived please share the groovy script for the same.

Thanks in Advance
Saberesh C P

1 Reply

  • wdowling's avatar
    wdowling
    Occasional Contributor
    I think based on the code below targetStep.properties.count() would also work to get the total elements in the properties list. but if u google the list structure in groovy it should tell you.


    def targetStep = testRunner.testCase.getTestStepByName( "Void request - REST Version 1" );
    targetStep.properties.each(){element ->
    if (element.value.toString() ==~ /.*RestTestStepProperty.*/){
            // this is a property ffor the request defined by the WADL
    log.info(element.key) // the name of the property
    log.info(element.value.getType()) // get the type assigned to the property by the WADL
    }
    }