Hi
Im trying to upload a dicom to /instances using php cURL, it uploads without any issue and logs into orthanc and shows up on explorer, but the curl script is not giving back any response after upload, it used to give back response with ID,Path,Status etc on an old version, but now it returns empty(no response) instead of any response, when i tried using the Postman to upload file, it responds with a body with the details said above
Hi Jaris,
Orthanc always returns the same response, whatever the HTTP client → I would strongly recommend that you double check your PHP code.
Best regards,
Alain
Hi,
From memory there is a different response if the post method uses form encoding vs if it has raw data. From memory, if the body is form encoded then orthanc returns an empty 200 response. Vs if the body is raw data then a json response is returned. I would suggest checking how the body of the request is encoded.
Hth
James
You might want to check the CURL options in your PHP script:
I’ve got some old scripts that used something like this with native PHP:
public function executeCURLPUT($data, $CURLOPT_URL) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->OrthancURL . $CURLOPT_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
self::logVariable("executeCURL: " . $this->OrthancURL . $CURLOPT_URL);
$headers = self::$headers;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return $this->processCURLResults($ch);
}
and you can also use composer to add Guzzle: https://packagist.org/packages/guzzlehttp/guzzle and https://docs.guzzlephp.org/en/stable/overview.html
e.g. $result = (new OrthancAPI())->GuzzleAPI(“POST”, “tools/create-dicom”, $JSONQuery);
That is a lot easier to use. If you are using Laravel or another framework they probably have built-in functions as well.
Stephen D. Scotti
Thanks for the suggestions, i will check it out