jquery - 415 Unsupported Media Type Cowboy REST Ajax -


i having problem cowboy rest request method post. works fine if post done submitting form content, response when use ajax send post content server.

the error response : 415 unsupported media type

here code content_types_provided , 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 idea on case?

why separate ?

try it:

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}. 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -