Patty Patty - 11 months ago 48
Java Question

Java equivallent code for curl

This is the curl command that I need to translate into java code:

curl ­-X PUT ­-H "Authorization: Bearer [redacted]" -­H "Content­Type: multipart/form­data;" -­F "records=9f9f1eb7bab4e882000a90864ebc3c1549211b2207a6fe741ecd06779fbc0d88,e8a727eb74d26047e1cbca5c21fe30d471f9a02c90a35a407737775e9728dda5" -­F "name=Test New User List Name 002" ""

My main confusion is if "-F" should be part of header/body/param-list-in-URL for a http post.

May I get help on this?


man curl

-F, --form (HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.

Example, to send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:

curl -F password=@/etc/passwd