0

I'm trying to convert Postman request to cURL format, but it doesn't work well. I would like to send a request with form-data includes csv file(with Content-Type url form encoded). It works when I try with Postman, but not works when i try with converted cURL code via Postman.

I attach my postman setting and cURL code converted via Postman. Should I have to handle something to send a file with cURL?

(english correction also welcome!) enter image description here enter image description here

zingoworks
  • 63
  • 2
  • 8

3 Answers3

1

Curl's default Content-Type is application/x-www-form-urlencoded so your problem is probably that the data you are POSTing is not actually form data. It might work if you set the content type header properly:

curl -X POST "your_url" -H "Content-Type: text/csv" -F "csvfile=@sample.csv"

Q.u.a.n.g L.
  • 1,564
  • 1
  • 12
  • 27
1

Cleared and left the success cases.
Thank you for the answer! And I also referred to below page too!

use curl to POST multipart/form-data, file and lots of key-value pairs

curl -v -X POST 'somewhere' \
--form 'key="value"' \
--form csvfile=@"filePath/sample.csv;type=text/csv"

curl -v -X POST 'somewhere' \
--form 'key=value' \
--form csvfile=@"filePath/sample.csv;type=multipart/form-data"
zingoworks
  • 63
  • 2
  • 8
0

Drop content-type-header from the generated code. then you should be good to go.

cedric
  • 331
  • 1
  • 6