karate Multi-values in a post request

Viewed 89

I have de following scenario in karate:

Scenario:
Given url 'http://my-url.com'
And form field items = ['item1','item2']
When method post

And thats the request processed:

1 > POST http://my-url.com
1 > Content-Type: application/x-www-form-urlencoded
1 > Content-Length: 19
1 > Host: my-url.com
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_281)
1 > Accept-Encoding: gzip,deflate
items=item1%26item2

But really... what I'm trying to do is the following request:

1 > POST http://my-url.com
1 > Content-Type: application/x-www-form-urlencoded
1 > Content-Length: 19
1 > Host: my-url.com
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_281)
1 > Accept-Encoding: gzip,deflate
items=item1&items=item2
```

Is it possible with karate framework? 

Thanks!
1 Answers

Thanks, you have found a bug which we are tracking here: https://github.com/karatelabs/karate/issues/1862

Fortunately I think you have a workaround. Just repeat the field items. Let me know if this works:

* url 'https://httpbin.org/anything'
* form field items = 'item1'
* form field items = 'item2'
* method post
Related