I am using skylight trying to configure simple api requests via guzzle.
The problem is that the base_uri parameter does not display correctly on the initial new Client() .
A simplified example:
use GuzzleHttp\Client; $client = new Client([ 'base_uri' => 'https://siteurl.com/api/v2' ]);
Then call api via get
$res = $client->get('orders', [ 'query' => [ 'status' => 'completed' ] ]);
does not work. I tried not to use absolute URLs like /orders for example. If I get $client->get('https://siteurl.com/api/v2/orders') completely and just add it to the get $client->get('https://siteurl.com/api/v2/orders') method, it works.
I use: "laravel / lumen-framework": "5.0. *", "Guzzlehttp / guzzle": "^ 6.0"
* Subsequent:
I added a debug flag to compare the headers, and a noticeable difference is in the query string of the request.
The absolute URL of the get method (bypassing base_uri):
GET / api / v2 / orders? status = completed HTTP / 1.1
Using base_uri (version loses):
GET / api / orders? status = completed HTTP / 1.1
lumen guzzle
drrobotnik
source share