A simple fix could be Content-Type: application/json
You are probably making a REST API call to get the response.
Mostly you are not setting Content-Type: application/json
when you the request.
Content-Type: application/x-www-form-urlencoded
will be chosen which might be causing this exception.