I'm using the following command to update a database (the line breaks are vital):
curl -X PUT -H 'Content-Type: multipart/form-data; boundary=myboundary' -d '--myboundary Content-ID: <request>
{"jsonKey":"jsonValue"} --myboundary-' 'http://target.url.com/path/to/folder'
This works correctly, but the PHP equivalent has problems:
$data = '--myboundary Content-ID: <request>
{"jsonKey":"jsonValue"} --myboundary-';
$handle = curl_init();
curl_setopt_array(
$handle,
array(
CURLOPT_URL => 'http://target.url.com/path/to/folder',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => 'Content-Type: multipart/form-data; boundary=myboundary',
CURLOPT_BINARYTRANSFER => true,
CURLOPT_POSTFIELDS => $data
)
);
$response = curl_exec($handle);
if($response === false){
echo 'curl error: ' . curl_error($handle);
}
curl_close($handle);
return $response;
It returns no error, but the data entered as json is set to null. I've checked everything else, but can't seem to find clear information on how cURL processes line breaks, and assume there is some difference between PHP breaks and console breaks.
Any insight into the issue of line breaks, or why this may not be working would be appreciated.
And in case anyone is thinking the obvious: no, I can't alter the database, or even view it (work regulations), and this needs to run from PHP (same reason).