lumen - base_uri not being based from guzzle client instantiation -
i'm using lumen trying set simple api requests via guzzle.
the problem base_uri parameter doesn't appear passed correctly on initial new client()
.
simplified example:
use guzzlehttp\client; $client = new client([ 'base_uri' => 'https://siteurl.com/api/v2' ]);
then calling api via get
$res = $client->get('orders', [ 'query' => [ 'status' => 'completed' ] ]);
does not work. i've been careful not use absolute urls /orders
. if bypass base_uri entirely , add on method $client->get('https://siteurl.com/api/v2/orders')
, works.
i'm using: "laravel/lumen-framework": "5.0.*", "guzzlehttp/guzzle": "^6.0"
*follow-up:
i added debug flag compare headers, , noticable difference in request line.
absolute url in method (bypassing base_uri):
get /api/v2/orders?status=completed http/1.1
using base_uri (version being stripped):
get /api/orders?status=completed http/1.1
you need terminate base_uri forward slash /
e.g.,
use guzzlehttp\client; $client = new client([ 'base_uri' => 'https://siteurl.com/api/v2/' ]);
edit: note base_uri guzzle 6+, whereas previous versions used base_url.
Comments
Post a Comment