Search code examples
javaspring-bootresttemplate

How to pass different datatypes values in RestTemplate FormData?


I'm trying to pass formdata through RestTemplate with different datatypes.

MultiValueMap<String, String> map = new MultiValueMap<String, String>();
map..set("app_id", 12);
map..set("app_name", "Partner");

But the api I'm hitting throwing Bad request, I tried from postman same request works fine.

Is there any other way I can pass multidatatype request in restemplate formdata?


Solution

  • You can use Object in this case :

    MultiValueMap<String, Object> map = new MultiValueMap<>();