Question

The post request code that I use:

def http = new HTTPBuilder(uri)
http.request(Method.POST, ContentType.TEXT){
    send ContentType.URLENC, attrs

    ..Response handler code...         
}

here attrs is a map with the key&value that needs to be passed such as:

[param1:'value1', param2:'value2', param3:'value3]

I need to support passing multiple values for the same parameter, hence passing as a map is not an option. What is my alternative in this case? What I need to pass:

[param1:'value1', param1:'value2', param3:'value3']
Was it helpful?

Solution

You should be able to do:

send URLENC, [param1:['value1','value2'], param3:'value3']

Your example won't work as a map can't have multiple keys with the same name

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top