federicotdn / verb

Organize and send HTTP requests from Emacs
https://melpa.org/#/verb
GNU General Public License v3.0
545 stars 20 forks source link

form-data key-value example #76

Closed kostafey closed 1 month ago

kostafey commented 2 months ago

Is there some example of using a simple form-data post request?

E.g. (unfortunately, it doesn't work):

post http://127.0.0.1:9000/handler
Content-Type: form-data

"paramName": "paramValue"
federicotdn commented 2 months ago

Hi, do you mean multipart/form-data?

kostafey commented 2 months ago

If I write

post http://127.0.0.1:9000/handler
Content-Type: multipart/form-data

paramName = paramValue

It generates (to curl):

curl 'http://127.0.0.1:9000/handler' \
-H 'Content-Type: multipart/form-data' \
-X POST \
--data-raw 'paramName = paramValue'

but I need the following one:

curl 'http://127.0.0.1:9000/handler' \
-H 'Content-Type: multipart/form-data' \
-X POST \
-F 'paramName = paramValue'
kostafey commented 2 months ago

The actual solution is:

post http://127.0.0.1:9000/handler
Content-Type: application/x-www-form-urlencoded

paramName=paramValue

(necessarily without spaces).

Would you like to add it to the README? Or can I add a pull request myself?

federicotdn commented 1 month ago

I don't think it is necessary to add to the README, since specifying that header value + the body format is not doing anything Verb-specific, just using Verb as it is intended to be used. Thank you for offering though.