Caroline
Caroline

Reputation: 311

How to use Curl to post contents of file in a form

I'm trying to post a list of identifiers as a form value from a file using curl. I've tried many different formats but each time the filename is posted rather than the actual data.

An example I have tried is below:

curl http:localhost:<port>/test --data "userId=User" --data "uploadIds=<test.txt"

curl http:localhost:<port>/test --data "userId=User" --data "[email protected]"

each of the above results in the filename being posted.

The file contains a comma-separated list of numbers.

Upvotes: 0

Views: 527

Answers (1)

Caroline
Caroline

Reputation: 311

Found the solution, the syntax I was looking for is:

curl http:localhost:<port>/test --data "userId=User" --data-urlencode [email protected]

Upvotes: 1

Related Questions