async icon indicating copy to clipboard operation
async copied to clipboard

Posting a form

Open jsicherman opened this issue 4 years ago • 4 comments

Hi,

There are no examples of how to use http_post to POST with content_type = multipart/form-data... I'm wondering how to format the structure of the form data and how to modify the headers to reflect the right request body.

Thanks!

jsicherman avatar Sep 09 '21 23:09 jsicherman

To be explicit, I want to do pretty much edit the http_post code to do this on the existing handle:

handle_setform(handle, OPTION1 = VALUE, OPTION2 = VALUE, ...)

I don't know how to do this with just postfields.

jsicherman avatar Sep 09 '21 23:09 jsicherman

Yes, the current approach is not great, and maybe it should let you simply pass in a handle for a request. OTOH, an easier fix might be to add a form_options argument to http_post(). Do you want to subnit a PR?

gaborcsardi avatar Sep 10 '21 07:09 gaborcsardi

Sure thing. I'll add handle to both http_get and http_post and form_data to the latter.

jsicherman avatar Sep 10 '21 15:09 jsicherman

Maybe form_data is enough for now? Thanks!

gaborcsardi avatar Sep 10 '21 15:09 gaborcsardi