Estoy tratando de consumir una API POST usando guzzlehttp en mi proyecto laravel. Pero recibo un error en mi servidor de desarrollo. Esto funciona perfectamente en mi sistema local. $postArray está manipulando correctamente ambos lados. Esta es mi versión de compositor. "guzzlehttp/guzzle": "^7.3", Si alguien sabe sobre esto, por favor ayúdeme.
$response = Http::withHeaders([ "accept: application/json", "content-type: application/json" ])->post('https://staging.consume.com/testing', $postArray)->json();strtolower(): El argumento #1 ($string) debe ser de tipo string, int dado
{ "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": "::" },Enfrenté el mismo problema, y cuando busqué, llegué a esta página.
Así es como lo resolví.
$response = Http::withHeaders([ "accept" => "application/json", "content-type" => "application/json" ])->post('https://staging.consume.com/testing', $postArray)->json();