read PUT request param

17 views
Skip to first unread message

Phang Mulianto

unread,
Nov 17, 2016, 8:18:44 AM11/17/16
to ChicagoBoss
hi,

i try to read a PUT request data, but cannot get the value.

With post, i use the documented way, Req:post_param("first_name").

how do i read the value of first_name from the form submit by PUT request, not POST request.

Thanks,

M

Graeme Defty

unread,
Nov 17, 2016, 10:37:19 AM11/17/16
to chica...@googlegroups.com
Hi,

Try Req:post_param(<<"first_name">>)

Graeme



--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/3dde27fc-b1f1-444e-9bd5-81638915651b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phang Mulianto

unread,
Nov 20, 2016, 11:22:14 AM11/20/16
to ChicagoBoss
Hi, 

I try it and the same, i get undefined.

The PUT request is a JSON request, not from a form as this sent from a SPA application.

But i manage to get the data from the Req:request_body() and process it like below.

    {struct, Body} = mochijson2:decode(Req:request_body()),
    Fname = proplists:get_value(<<"first_name">>,Body, "None"),

now i can get the PUT request, same with POST request with json incoming data.

Any better way on handling this? i got above from this old mail thread here and its works.

Thanks,

Mulianto

On Thursday, 17 November 2016 23:37:19 UTC+8, graeme defty wrote:
Hi,

Try Req:post_param(<<"first_name">>)

Graeme


On 17 November 2016 at 20:18, Phang Mulianto <brav...@gmail.com> wrote:
hi,

i try to read a PUT request data, but cannot get the value.

With post, i use the documented way, Req:post_param("first_name").

how do i read the value of first_name from the form submit by PUT request, not POST request.

Thanks,

M

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages