响应应该是XML,但在使用标头将请求发送到REST API时,我得到了类似(56): Failure when receiving data from the peer
的错误。以下是根据客户端的示例请求
POST http://api.toyotautrust.in/1.0/olx/inventory HTTP/1.1
User-Agent: Fiddler
Authorization: Token ******-****-****-****-***********
Host: api.toyotautrust.in
Content-Length: 52
下面是我使用cURL用PHP编写的请求代码
$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;
1条答案
按热度按时间6kkfgxo01#
我未能在POST请求中发送这两个标头
添加这两个头后,它就可以正常工作了。在发送请求到服务器之前,请询问服务器端人员有关头和参数的信息