Using request arguments

33 views
Skip to first unread message

Jean Amiouny

unread,
Jan 17, 2015, 11:02:00 PM1/17/15
to websc...@googlegroups.com
Hi,

I'm fairly new to LUA. I've been trying to use arguments passed in my request in the LUA script.

My requests have this object passed:

{"desc":"this is a test","tok":"123974329742"}

how would I use the 'desc' for example in this http.request:

local response = http.request {
url = 'http://google.com',
params = { 
q=request.desc
},
method = "POST"
}
return response.content

Thanks! 

Steve Marx

unread,
Jan 17, 2015, 11:05:15 PM1/17/15
to Jean Amiouny, websc...@googlegroups.com

How are the arguments being passed? Query parameters? Form post? JSON in the request body?

If you're not sure, please paste a request from your log here so I can see.

--
You received this message because you are subscribed to the Google Groups "Webscript.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webscriptio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Jean Amiouny

unread,
Jan 17, 2015, 11:23:26 PM1/17/15
to websc...@googlegroups.com, jean.a...@gmail.com
Hey thanks for the quick reply!

I'm using a POST through angularjs:

var req = {
                    method: 'POST',
                    url: 'https://SUB.webscript.io/SCRIPT',
                    data: {
                        desc: $scope.desc,
                        tok: result.id
                    }
                }
                $http(req)

Steve Marx

unread,
Jan 17, 2015, 11:41:31 PM1/17/15
to Jean Amiouny, websc...@googlegroups.com

Resending since I'm not sure my first reply made it through:

Hmm. I still don't know what that does. :-) (I don't know what Angular does here.)

But my guess would be that the data is passed as JSON in the request body, so you would want something like this: json.parse(request.body).desc.

Jean Amiouny

unread,
Jan 18, 2015, 1:04:21 AM1/18/15
to websc...@googlegroups.com, jean.a...@gmail.com
Yes! That went through.

Thanks Steve for the super quick reply :)
Reply all
Reply to author
Forward
0 new messages