Java – use Multimap instead of map to send parameters of rest assured call
•
Java
I'm declaring a variable
static Multimap<String,Object> multiList = ArrayListMultimap.create();
And add image
multiList.put(**key1**,value1) multiList.put(**key1**,value1) multiList.put(**key2**,value3)
Now, my request is like
Response response = RestAssured.given().header("Cookie",SessionDetailsCedar.CSESSIONID).and().header("X-CSRFToken",SessionDetailsCedar.CSRF).and().header("Content-Type","application/x-www-form-urlencoded; charset=UTF-8").and().header("Connection","keep-alive").formParameters(<b>multiList</b>).when().post(<b>Some URL</b>);
My problem is that when I want to use Multimap, formparameters (map) only uses map as a parameter
Solution
Multimap cannot be converted to map because it corresponds to the definition of map In this case, I think you should use another method of rest, formparam method, as shown in the following example:
RestAssured. given(). contentType("application/x-www-form-urlencoded; charset=ISO-8859-1"). formParam("key1",value1). formParam("key1",value2). formParam("key2",value3). when(). post("Some URL");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码