7

Can anyone tell me if I can (in the command line) issue a POST command that contains a file and other parameters?

I am trying to do something like:

curl -X POST -F "key=myKey&file=@myfile.txt"  http://localhost:8080/myRestService/

I am really new in this domain, so excuse me for my basic question. But it does not seems to work well. Any suggestion? Tank you very much

Rami
  • 8,044
  • 18
  • 66
  • 108

1 Answers1

6

You should use -d param

check a man page http://curl.haxx.se/docs/manpage.html

If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be URL-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.

Try to specify a full path to your file.

lc0
  • 654
  • 4
  • 9