0

I am trying to set the base URI for API requests on my GuzzleHTTP instance but am having issues with it dropping the path. According to the docs, a URI of https://api.app.com/v2/ should return that as the path but on my project it is dropping the v2 and just returning https://api.app.com

$this->client = new Client([
    'base_uri' => $this->baseUri // baseUri == https://api.app.com/v2/
]);

base_uri should be https://api.app.com/v2/ not https://api.app.com

Joe Scotto
  • 10,936
  • 14
  • 66
  • 136
  • May you add a little more context? You create a new client and then? How do you issue the request? Have you a slash in front of the relative url [http://docs.guzzlephp.org/en/stable/quickstart.html?highlight=base_uri](is this the docs you refer?) – Eineki Dec 13 '19 at 14:23

1 Answers1

3

The issue was coming from the way I was running a request. I was prepending a / onto the endpoint and according to the docs, you need to omit this in order to properly request while using base_uri

So instead of $this->client->get('/endpoint') it needs to be $this->client->get('endpoint')

Joe Scotto
  • 10,936
  • 14
  • 66
  • 136