<div dir="ltr"><div dir="ltr"><div>Thank you Loic and Zsolt that helped, my bad didn't RTFM properly :(  Now I'm facing a different Issue. <br></div><div><br></div><div><b>But something that still baffles me why is this only happening when calling from POSTMAN and not CURL.</b> <i>I'm on a Arch Linux machine with Sway/Wayland Compositor. </i></div><div><br></div><div>New error stacktrace after changing return value from <i>hello_json </i>handler:<br></div><div><br></div><div>=CRASH REPORT==== 2-Apr-2019::16:20:53.649647 ===<br>  crasher:<br>    initial call: cowboy_stream_h:request_process/3<br>    pid: <0.445.0><br>    registered_name: []<br>    exception error: function_clause<br>      in function  cowboy_req:reply/4 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_req.erl, line 763)<br>      in call from cowboy_rest:respond/3 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, line 1616) <br>      in call from cowboy_rest:process_content_type/3 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, line 1106)<br>      in call from cowboy_rest:upgrade/4 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, line 288)<br>      in call from cowboy_stream_h:execute/3 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, line 296)<br>      in call from cowboy_stream_h:request_process/3 (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, line 274)<br>    ancestors: [<0.444.0>,<0.407.0>,<0.406.0>,ranch_sup,<0.395.0>]<br>    message_queue_len: 0<br>    messages: []<br>    links: [<0.444.0>]<br>    dictionary: []<br>    trap_exit: false<br>    status: running<br>    heap_size: 1598<br>    stack_size: 27<br>    reductions: 782<br>  neighbours:<br><br>=ERROR REPORT==== 2-Apr-2019::16:20:53.651090 ===<br>Ranch listener my_http_listener, connection process <0.444.0>, stream 1 had its request process <0.445.0> exit with reason function_clause and stacktrace [{cowboy_req,reply,4,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_req.erl"},{line,763}]},{cowboy_rest,respond,3,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,1616}]},{cowboy_rest,process_content_type,3,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,1106}]},{cowboy_rest,upgrade,4,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,288}]},{cowboy_stream_h,execute,3,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl"},{line,296}]},{cowboy_stream_h,request_process,3,[{file,"/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl"},{line,274}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]<br><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 2, 2019 at 3:06 PM Loïc Hoguin <<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Your hello_post function is returning Req instead of {boolean(), Req, <br>
State}.<br>
<br>
On 02/04/2019 17:04, maverik a wrote:<br>
> Hi Erlangers,<br>
> <br>
> I'm learning Cowboy and facing a peculiar issue.<br>
> *My handler code* is here. <<a href="https://pastebin.com/NQsrj1g0" rel="noreferrer" target="_blank">https://pastebin.com/NQsrj1g0</a>><br>
> <br>
> I have a rest endpoint (POST) and accessing it with Postman show a crash <br>
> report after giving response. But the very same request works find with <br>
> CURL.<br>
> <br>
> _*CURL Request*:_<br>
> curl -X POST -d '{"name":"M4ver1k"}' -i -H "User-Agent: <br>
> PostmanRuntime/7.6.1" -H "Cache-Control: no-cache" -H "postman-token: <br>
> cc241d1b-d2f0-488d-86ec-0a06bbb13234" -H "connection: keep-alive" -H <br>
> "Accept-Encoding: gzip, deflate" -H "Content-Type: application/json" -H <br>
> "Accept: application/json" <a href="http://localhost:8080/api/" rel="noreferrer" target="_blank">http://localhost:8080/api/</a><br>
> <br>
> _*Crash Report:*_<br>
> crasher:<br>
>      initial call: cowboy_stream_h:request_process/3<br>
>      pid: <0.1023.0><br>
>      registered_name: []<br>
>      exception error: no try clause matching<br>
>                       #{bindings => #{},body_length => 17,cert => undefined,<br>
>                         charset => undefined,has_body => true,<br>
>                         has_read_body => true,has_sent_resp => true,<br>
>                         headers =><br>
>                             #{<<"accept">> => <<"application/json">>,<br>
>                               <<"accept-encoding">> => <<"gzip, deflate">>,<br>
>                               <<"cache-control">> => <<"no-cache">>,<br>
>                               <<"connection">> => <<"keep-alive">>,<br>
>                               <<"content-length">> => <<"17">>,<br>
>                               <<"content-type">> => <<"application/json">>,<br>
>                               <<"host">> => <<"localhost:8080">>,<br>
>                               <<"postman-token">> =><br>
>                                   <br>
> <<"04b305c1-5214-461e-a1c3-8dcd6b80a621">>,<br>
>                               <<"user-agent">> => <br>
> <<"PostmanRuntime/7.6.1">>},<br>
>                         host => <<"localhost">>,host_info => undefined,<br>
>                         media_type => {<<"application">>,<<"json">>,[]},<br>
>                         method => <<"POST">>,path => <<"/api/">>,<br>
>                         path_info => undefined,<br>
>                         peer => {{127,0,0,1},59002},<br>
>                         pid => <0.1022.0>,port => 8080,qs => <<>>,<br>
>                         ref => my_http_listener,scheme => <<"http">>,<br>
>                         sock => {{127,0,0,1},8080},<br>
>                         streamid => 1,version => 'HTTP/1.1'}<br>
>        in function  cowboy_rest:call/3 <br>
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, <br>
> line 1576)<br>
>        in call from cowboy_rest:process_content_type/3 <br>
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, <br>
> line 1100)<br>
>        in call from cowboy_rest:upgrade/4 <br>
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_rest.erl, <br>
> line 288)<br>
>        in call from cowboy_stream_h:execute/3 <br>
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, <br>
> line 296)<br>
>        in call from cowboy_stream_h:request_process/3 <br>
> (/m4ver1k/learn/erlang/hello_cowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, <br>
> line 274)<br>
>      ancestors: [<0.1022.0>,<0.407.0>,<0.406.0>,ranch_sup,<0.395.0>]<br>
>      message_queue_len: 0<br>
>      messages: []<br>
>      links: [<0.1022.0>]<br>
>      dictionary: []<br>
>      trap_exit: false<br>
>      status: running<br>
>      heap_size: 1598<br>
>      stack_size: 27<br>
>      reductions: 770<br>
>    neighbours:<br>
> <br>
> <br>
> I have run out of options to triage this,trying to understand this <br>
> behavior.<br>
> <br>
> Regards<br>
> Maverick<br>
> <br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
> <br>
<br>
-- <br>
Loïc Hoguin<br>
<a href="https://ninenines.eu" rel="noreferrer" target="_blank">https://ninenines.eu</a><br>
</blockquote></div>