title: How to set status code in REST POST in cowboy
body: <p>How can I set status code in my REST POST resource.</p>
  
  <p>Now I'm doing this </p>
  
  <pre><code>make_post(Req, State) -&gt;
    lager:info("post"),
    Resp = cowboy_req:set_resp_body(&lt;&lt;"HELLO POST\n"&gt;&gt;, Req),
    {ok, Resp3} = cowboy_req:reply(201, Resp),
    {true, Resp3, State}.
  </code></pre>
  
  <p>But I receive such errors:</p>
  
  <p>1:43:10.510 [info] [nonode@nohost#pbshare_logic_registration#&lt;0.205.0>] [handle_info#35] :Exit Logic from &lt;0.204.0>  Reason: {function_clause,[{cowboy_req,reply,[204,[],&lt;&lt;>>,{http_req,#Port&lt;0.6355>,ranch_tcp,keepalive,&lt;0.204.0>,&lt;&lt;"POST">>,'HTTP/1.1',{{127,0,0,1},50024},&lt;&lt;"localhost">>,undefined,8080,&lt;&lt;"/rest/registration/make">>,[&lt;&lt;"make">>],&lt;&lt;>>,undefined,[],[{&lt;&lt;"user-agent">>,&lt;&lt;"curl/7.29.0">>},{&lt;&lt;"host">>,&lt;&lt;"localhost:8080">>},{&lt;&lt;"accept">>,&lt;&lt;"<em>/</em>">>},{&lt;&lt;"content-type">>,&lt;&lt;"application/json">>},{&lt;&lt;"content-length">>,&lt;&lt;"14">>}],[{&lt;&lt;"content-length">>,14},{&lt;&lt;"expect">>,undefined},{&lt;&lt;"content-length">>,14},{&lt;&lt;"content-type">>,{&lt;&lt;"application">>,&lt;&lt;"json">>,[]}},{&lt;&lt;"if-modified-since">>,undefined},{&lt;&lt;"if-none-match">>,undefined},{&lt;&lt;"if-unmodified-since">>,undefined},{&lt;&lt;"if-match">>,undefined},{&lt;&lt;"accept">>,[{{&lt;&lt;"<em>">>,&lt;&lt;"</em>">>,[]},1000,[]}]}],undefined,[{charset,undefined},{media_type,{&lt;&lt;"application">>,&lt;&lt;"json">>,[]}}],done,undefined,&lt;&lt;>>,false,done,[],&lt;&lt;>>,undefined}],[{file,"src/cowboy_req.erl"},{line,948}]},{cowboy_rest,respond,3,[{file,"src/cowboy_rest.erl"},{line,1085}]},{cowboy_rest,upgrade,4,[{file,"src/cowboy_rest.erl"},{line,75}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,523}]}]}
  21:43:10.510 [error] [Undefined#Undefined#emulator] [Undefined#Undefined] :Error in process &lt;0.204.0> with exit value: {function_clause,[{cowboy_req,reply,[204,[],&lt;&lt;0 bytes>>,{http_req,#Port&lt;0.6355>,ranch_tcp,keepalive,&lt;0.204.0>,&lt;&lt;4 bytes>>,'HTTP/1.1',{{127,0,0,1},50024},&lt;&lt;9 bytes>>,undefined,8080,&lt;&lt;23 bytes>>,[&lt;&lt;4 bytes>>],&lt;&lt;0 bytes>>,undefined,[],[{&lt;&lt;10 bytes>>,&lt;&lt;11 bytes>>},{&lt;&lt;4 bytes>>,&lt;&lt;14 bytes>>},{&lt;&lt;6 bytes>>,&lt;&lt;3 bytes>>},{&lt;&lt;12 bytes>>,&lt;&lt;16 bytes>>},{&lt;&lt;14 bytes>>,&lt;&lt;2 bytes>>}],[{&lt;&lt;14 bytes>>,14},{&lt;&lt;6 bytes>>,undefined},{&lt;&lt;14 bytes>>,14},{&lt;&lt;12 bytes>>,{&lt;&lt;11 bytes>>,&lt;&lt;4 bytes>>,[]}},{&lt;&lt;17 bytes>>,undefined},{&lt;&lt;13 bytes>>,undefined},{&lt;&lt;19 bytes>>,undefined},{&lt;&lt;8 bytes>>,undefined... </p>
  
  <p>It seems that cowboy tries to send response once again after my reply. But I didn't any other method in API which can change status code. </p>