How can I rewrite the following CURL command, so that it doesn\'t use the -F
option, but still generates the exact same HTTP request? i.e. so that it passes th
Here's an alternative answer with the original CURL statement re-written using -d
as a one-liner, without temporary files. Personally I think the temporary files approach is easier to understand, but I'm putting this here for reference as well:
curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------4ebf00fbcf09" -d $'------------------------------4ebf00fbcf09\r\nContent-Disposition: form-data; name="example"\r\n\r\ntest\r\n------------------------------4ebf00fbcf09--\r\n' http://localhost:3000/test
Notes: the $'blar'
syntax is so that bash will parse the \r\n as a CRLF token. Thanks to this answer for that tip.