php 在Laravel项目上guzzlehttp抛出错误- strtolower():参数#1($string)必须是string类型,给定int

e1xvtsh3  于 2023-08-02  发布在  PHP
关注(0)|答案(1)|浏览(277)

我尝试在我的Laravel项目中使用guzzlehttp使用POST API。但是我在我的开发服务器上遇到了一个错误。这在我的本地系统上运行得很好。$postArray正确操作了两侧。这是我在Composer中的Guzzle版本:"guzzlehttp/guzzle": "^7.3"
代码:

$response = Http::withHeaders([
            "accept: application/json",
            "content-type: application/json"
        ])->post('https://staging.consume.com/testing', $postArray)->json();

字符串
错误代码:
strtolower():参数#1($string)必须是string类型,给定int
JSON:

{
"message": "strtolower(): Argument #1 ($string) must be of type string, int given",
"exception": "TypeError",
"file": "/mnt/drive_1/www/deploy-api-2021-07-29-14-25-12/vendor/guzzlehttp/psr7/src/Utils.php",
"line": 28,
"trace": [
    {
        "file": "/mnt/drive_1/www/deploy-api-2021-07-29-14-25-12/vendor/guzzlehttp/psr7/src/Utils.php",
        "line": 28,
        "function": "strtolower"
    },
    {
        "file": "/mnt/drive_1/www/deploy-api-2021-07-29-14-25-12/vendor/guzzlehttp/psr7/src/Utils.php",
        "line": 189,
        "function": "caselessRemove",
        "class": "GuzzleHttp\\Psr7\\Utils",
        "type": "::"
    },
    {
        "file": "/mnt/drive_1/www/deploy-api-2021-07-29-14-25-12/vendor/guzzlehttp/guzzle/src/Client.php",
        "line": 455,
        "function": "modifyRequest",
        "class": "GuzzleHttp\\Psr7\\Utils",
        "type": "::"
    },

3htmauhk

3htmauhk1#

我遇到了同样的问题,当我搜索时,我到达了这个页面。
我是这么解决的。

$response = Http::withHeaders([
            "accept" => "application/json",
            "content-type" => "application/json"
        ])->post('https://staging.consume.com/testing', $postArray)->json();

字符串

相关问题