Page 1 of 1
Make a POST with application/x-www-form-urlencoded payload
Posted: Wednesday 28 October 2020 9:31
by Number8
Hello,
I have to send a POST with an application/x-www-form-urlencoded payload. I'm wondering what the syntax should be?
Current script is:
Code: Select all
dz.openURL({
url = url,
method = "POST",
callback = "return",
postData = {
turn = "toggle"
}
})
Thank you
Re: Make a POST with application/x-www-form-urlencoded payload
Posted: Wednesday 28 October 2020 9:59
by waaren
Number8 wrote: Wednesday 28 October 2020 9:31
I have to send a POST with an application/x-www-form-urlencoded payload. I'm wondering what the syntax should be?
Something like this ?
Code: Select all
dz.openURL({
url = url,
method = 'POST',
headers = { ['content-Type'] = 'application/x-www-form-urlencoded' },
postData = { ['turn'] = 'toggle' },
callback = 'return',
})
Re: Make a POST with application/x-www-form-urlencoded payload
Posted: Wednesday 28 October 2020 10:30
by Number8
Thanks waaren
Unfortunately it does not work, I don't know why. Strange the API does not return any error.
Using GET however works
Re: Make a POST with application/x-www-form-urlencoded payload
Posted: Thursday 05 November 2020 17:18
by Number8
Using this curl command works
Code: Select all
curl -X POST -d "turn=toggle" http://IPaddress/relay/0
What would be then dzVents syntax?
Re: Make a POST with application/x-www-form-urlencoded payload [Solved]
Posted: Sunday 08 November 2020 15:17
by Number8
The correct syntax is
Code: Select all
dz.openURL({
url = url,
method = 'POST',
postData = { turn = 'on' },
callback = 'return'
})