User0911
User0911

Reputation: 1582

SNS not able to hit HTTPS endpoint

I have below annotation set on my controller but it is not able to receive AWS SNS messages,

@RequestMapping(method = RequestMethod.POST, headers = "Content-Type=text/plain; charset=UTF-8")

SNS message sample is here

I always get 415 Unsupported Media Type. Looks like I am missing some minor thing here.

Upvotes: 1

Views: 834

Answers (1)

Roopak Nijhara
Roopak Nijhara

Reputation: 21

This what worked for me:

The request body is actually a JSON string (text/plain) so you should accept it as a string and then parse it to a usable structure.

Here is an example.

@RequestMapping(method = RequestMethod.POST, consumes = "text/plain")
void subscribe(@RequestBody String paramsString) {
    Map<String, String> params = new Gson().fromJson(paramsString, new 
HashMap<String, String>().getClass());
    // Use params..
}

Upvotes: 2

Related Questions