--data-urlencode curl to nodeJS request or express module --data-urlencode curl to nodeJS request or express module node.js node.js

--data-urlencode curl to nodeJS request or express module


From curl documentation :

--data-urlencode

(HTTP) This posts data, similar to the other -d, --data options with the exception that this performs URL-encoding.

So you would use form option to send form URL encoded like this :

var options = {    url: 'url',    method: 'POST',    auth: {        'user': 'user',        'pass': 'pass'    },    form: {        To: 'phone',        From: 'phone',        Body: 'message'    },    headers: {        'Accept': '*/*'    }};

Note that you can use request-debug to show the actual request where you could check that body is :

To=phone&From=phone&Body=message

And to show the actual data sent by curl use as stated here, use --trace-ascii /dev/stdout :

curl '<url>' -X POST --data-urlencode "Body=<message>" -u <user>:<pass>  --trace-ascii /dev/stdout