I'm trying to send a JSON that contains a map in a POST request using postman. I've already tried numerous combinations, unfortunately to no avail.
I set Content-Type to application/json. I've seen this question: Sending map in postman post request, but the advice provided there doesn't help.
Here's what I've tried so far:
Key is payload
, then Value is:
- {message: message1, country:germany},
- {"message": message1, "country":germany},
- {"message": "message1", "country":"germany"},
- Some other options with numerous escaping attempts - none of them works.
Here are some java classes that are supposed to handle this:
@RequestMapping(method = RequestMethod.POST, value = "/send/singleUserReq")
@ResponseBody
public String sendNotificationToSingleUser(@RequestBody SingleUserRequest singleUserRequest) {
//...
}
public abstract class Request {
private String deviceType;
private Map<String, String> payload;
private String appId;
}
public class SingleUserRequest extends Request {
private String deviceId;
}
EDIT:
When I send the following request with postman:
http://localhost:8080/api/send/singleUserReq?deviceType=ios&payload={"message": "message1", "country":"germany"}&appId=appName1&deviceId=12345
I get this error on the java side: Invalid character found in the request target [/api/send/singleUserReq?deviceType=ios&payload={%22message%22:%20%22message1%22,%20%22country%22:%22germany%22}&appId=appName1&deviceId=12345]. The valid characters are defined in RFC 7230 and RFC 3986