php - cURL请求已重试3次,但未成功

标签 php laravel laravel-5 runtime-error guzzle

我目前正在使用(Guzzle client/Laravel)对自定义API进行rest API调用。我通过添加错误的 body 尝试了几次。我收到以下错误

cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)



以下是我的开发环境的详细信息:
 Language : php,
 Framework : Laravel 5.4,
 Client : Guzzle,
 OS : Ubuntu 16.04

我想知道这背后的原因

请在这件事上帮助我,

谢谢

以下是我的代码
{
    $headers = [
                'Content-Type' => 'application/json',
                'Authorization' => 'Bearer '.$this->accessTocken,
                'Accept' => 'application/json',
            ];

            $Body = [
                'method' => 'AndroidApp',
                'msisdn' => '94777400725',
            ];

            $client = new Client();

            $response = $client->post( $this->url, ['headers'=> $headers, 
             'json'=> $Body]);
}

最佳答案

$ response-> getBody()-> rewind();

为我工作

关于php - cURL请求已重试3次,但未成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58112931/

相关文章:

php - Mysql 将连接表作为子数组返回

javascript - 现有 PHP/JS 代码在导入语句中显示错误

php - Laravel 5.1.19 artisan 制作 :auth is not available

javascript - 有没有办法在 HTML 中将 PHP 对象作为 JavaScript 参数传递?

php - mysql 价格范围 with 或 in range

php - ->where() 不工作,知道吗?

php - 正确使用 mkdir()

Laravel 5.4 Backpack 无法删除项目,返回 "403 Forbidden"错误

laravel - 如何开始使用语义 UI

mysql - 当该表中的列不可用时如何按 ASC 进行排序