this is my scenario. a web application written in PHP (7.x) that a certain point sends some informations and 2 files to a web server via cURL. The web server have some Rest APIs also written in PHP (7.x).
my problem is that when I send the files, IIS (7.5) on the server (Win 2008 R2) return an "500 internal server error". Looking to error details the error code is "0x80070026"
If I deploy the API on another server with Apache the API runs fine. On IIS I've done some tests and: - If I send the cURL command without the files the API runs fine. - If I call the API with Postman and with files attached the API runs fine too.
web app have this code
$url = $this->config->item('API_endpoint').'Scans/scans/';
$username = $this->config->item('API_username');
$password = $this->config->item('API_password');
//$header = array('Content-Type: multipart/form-data');
$postData = array(
'scanDate' => date('Y-m-d H:i:s'),
...other data...
'file1' => curl_file_create('file1.stl'),
'file2' => curl_file_create('file2.stl')
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLOPT_HEADER, false);
$result=curl_exec($ch);
The script on the server read the data and save the files.
I tried also to add
curl_setopt(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
IIS logs show
2020-06-09 10:37:27 172.31.2.11 POST /index.php/Scans/scans/ - yyyy - x.x.x.x Mozilla/4.0+(Compatible;+MSIE+5.01;+Windows+NT+5.0) 500 0 38 405
thanks!
edit: in my curl script I've added a var_dump($result);
I had a similar issue with PHP 7.3 on IIS, with wireshark I found that CURL sends 100-continue requests just after the original POST request, POSTMAN does not.
I added the option
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
To my curl request to aviod it
This made CURL to stop sending 100-continue and IIS does not throw 500 with error code x80070026 any more.
User contributions licensed under CC BY-SA 3.0