'Error (56): Failure when receiving data from the peer for rest API post method request using PHP

The Response should be XML, but i'm getting error like (56): Failure when receiving data from the peer while sending the request to REST API using headers, Here is the sample request according to the client

POST http://api.toyotautrust.in/1.0/olx/inventory HTTP/1.1
User-Agent: Fiddler
Authorization: Token ******-****-****-****-***********
Host: api.toyotautrust.in
Content-Length: 52

Here is my Request code written in PHP using cURL

$headers1=[
'POST /1.0/olx/inventory HTTP/1.1',
        'Host: api.toyotautrust.in',
        'User-Agent: Fiddler',
        'Authorization: Token' .$atoken1,
        'Content-Length: 52'];
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, 'http://api.toyotautrust.in/1.0/olx/inventory');
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_HEADER, true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_HTTPHEADER,$headers1);
$response1 = curl_exec($ch1);
print_r($response1);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $status_code1;


Solution 1:[1]

I have failed to send these two header in POST request

'User-Agent:Fiddler',
"Content-length: 0",

After adding these two headers, it's working fine. Before sending your request to server, Please ask server side people about headers and parameters

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sri P