I am having a problem with cowboy REST request with method POST. It works fine if the POST done by submitting the Form content, but it will response when I use AJAX to send POST content to the server.
The error response is : 415 Unsupported Media Type
Here is my code for content_types_provided and content_types_accepted
content_types_accepted(Req, State) ->
Handler = [
{<<"text/html">>, handle_post_html},
{{<<"application">>,<<"json">>, []}, handle_post_html},
{{<<"text">>, <<"plain">>, []}, handle_post_html}],
{Handler, Req, State}.
content_types_provided(Req, State)->
Handler = [
{<<"text/html">>, parse_html},
{<<"application/json">>, parse_json},
{<<"text/plain">>, parse_plain_text}],
{Handler, Req, State}.
Any body has any idea on this case?
Reqand find which content type it contains. I think you should use something like{<<"application">>, <<"x-www-form-urlencoded">>, []}- P_A