Answer the question
In order to leave comments, you need to log in
Why doesn't CURL render the body?
The story begins with an attempt to send a file to a service. The service expects file(binary), so I do something like this:
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
'file' => new CurlFile($_FILES['image']['tmp_name'])
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Required request body is missing:
Answer the question
In order to leave comments, you need to log in
1. The service expects a single field file? No others?
2. If instead of $_FILES[] we just take some test file, what is, for example, in the same directory with the script?
3. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true) try.
4. See curl_getinfo() for details.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question