web services - PHP Curl http code 100 and failing -


i'm trying use web service php curl i'm getting http code "100" , "recv failure: connection reset" error.. tested web service google chrome's extension "postman -rest client" , works perfectly. searched http code , looks server expecting body request data don't know it's expecting me send since i'm not posting data, headers.

my code looks this:

error_reporting(-1);      $header = array('content-length: 1831', 'content-type: application/json', 'authorization: '. $authorization, 'authorization-admin: '. $authorization_admin);     $url = 'http://api.bookingreports.com/public/1/analytics/reports/departures';       $ch = curl_init($url);      curl_setopt($ch, curlopt_post, true);      curl_setopt($ch, curlopt_httpheader, $header);     curl_setopt($ch, curlopt_returntransfer, true);      curl_setopt($ch, curlinfo_header_out, true);       $result = curl_exec($ch);      $errorcode = curl_getinfo($ch, curlinfo_header_out);     $httpcode = curl_getinfo($ch, curlinfo_http_code);      echo $result;     echo curl_error($ch);     echo $errorcode;     echo $httpcode;      //log_message('debug', 'http header '. $errorcode);      curl_close($ch); 

and header i'm sending looks this:

post /public/1/analytics/reports/departures http/1.1 host: api.bookingreports.com accept: */* content-length: 1831 content-type: application/json authorization: myauthcode authorization-admin: myauthadmin expect: 100-continue 

you're sending wrong content-length value. that's why server expects request body. because aren't sending data, content-length should set 0.

$header = array('content-length: 0', 'content-type: application/json', 'authorization: '. $authorization, 'authorization-admin: '. $authorization_admin); 

when decide compose request header manually, make sure content-length set correct value.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -