Search code examples
javarestspring-bootcucumber-jvmrest-assured

RestAssured: Making a GET request with a parameters map


I am unable to make a RestAssured Get request (with params)

Map<String, String> paramsMap = generateParametersMap(parameters); rs = RestAssured.get(url,paramsMap);

the url is an end point - which I am able to hit a 200 in the browser.

The controller for the above request:

@RequestMapping(value = "/getMovieYear", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public int fetchMovieYear(@RequestParam("movieName")String movieName) throws Exception{ .. }

The stack trace for the above:

java.lang.IllegalArgumentException: You specified too many path parameters (1).
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

The parameters(1) is saying I am trying to pass one parameter. But I see no luck in getting this to work.


Solution

  • This worked for me RestAssured.given().param(paramsMap).when().get(url)