I need to send a POST request with curl via command line. ContentType needs to be multipart/form-data
My payload is JSON, but it's really big, so I can't send it directly via curl (Argument list too long). Instead I need to require the content via a file
Without getting the content from a file everything works fine
curl "https://domain/endpoint.php" \
-F "jsondata={\"jsonkey\":\"jsonvalue\"};type=application/json"
=>
array(1) {
["jsondata"]=>
string(23) "{"jsonkey":"jsonvalue"}"
}
(sent as multipart/form-data)
But when I put the same (small test) json in a file and use that in my curl command. The result on the server side is different
curl "https://domain/endpoint.php" \
-F "jsondata=@curl_data3.json;type=application/json"
=>
array(1) {
["jsondata"]=>
array(5) {
["name"]=>
string(15) "curl_data3.json"
["type"]=>
string(16) "application/json"
["tmp_name"]=>
string(14) "/tmp/php5k58m4"
["error"]=>
int(0)
["size"]=>
int(23)
}
}
The file (curl_data3.json) just contains {"jsonkey":"jsonvalue"}
It seems like I'm just sending the file itself and not the content of the file :-/