guzzle 使用 json方式请求接口

  • 在调用接口的时候有些接口要求请求方式为json方式,在guzzle该如何去使用

  • 以数组的方式请求,加上json键

$client->request('POST', 'http://10.1.11.207:8080/api/v2/otherin/add', [
            'json' => [
                'otherin' => [
                    'warehousecode' => '02',
                    'receivecode' => '104',
                    'maker' => '张桑',
                    'handler' => '李四',
                    'entry' => [
                        "inventorycode" => "11-C-06-0055",
                        "cost" => "7777",
                        "serial" => "20210625",
                        "quantity" => "7"
                    ]
                ]
            ]
        ])

Guess you like

Origin blog.csdn.net/weixin_43674113/article/details/118938990