Best regards, I’m using Guzzle 7 with Laravel 8, and I need to pass a path variable, at least that’s how it is called with postman, this my code
$client = new GuzzleHttpClient();
$response = $client->get('xxxxxxxxxxxxxx', [ 'params' => ['dni' => 'xxxxxxx'], 'headers' => ['x-api-key' => 'xxxxxxxxx'] ]);
dd($response);
but it is as if it does not send anything, I would really appreciate if someone knows how to do this query
2
Answers
The guzzle request must look like this:
This means that you must replace
params
withquery
.https://docs.guzzlephp.org/en/stable/quickstart.html#query-string-parameters
Instead of using Guzzle, use the native
Http
facade that is available since Laravel 7.x. Using the facade, you have a dedicated section about what you want here.So, your code should be like this:
And if you want to pass more params, just add index and value, and that’s it!