Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

danilchican's avatar

Cannot execute API call to another Laravel website

Hi everyone!

Today I was trying to execute API call with Guzzle to another service. But the problem is that if I do the request locally to that service, it works fine. it should be mentioned that when the service was at Modx such error still reproduced. Currently service is replaced by Laravel app.

But when I do the request from the dev server if fails with following error:

`GET http://mysite.com/api/v1/products?codes=1` resulted in a `415 Unsupported Media Type` response:


production.ERROR: #0 /home/..../vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/..../vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/.../vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)

The following response headers present:

{"responseHeaders":{"Date":["Mon, 04 Jan 2021 10:43:42 GMT"],"Content-Type":["application/octet-stream"],"Transfer-Encoding":["chunked"],"Connection":["close"],"Server":["imunify360-webshield/1.13"]},"responseProtocol":"1.1"}

Can anyone help me?

0 likes
1 reply
danilchican's avatar

file_get_contents() returns the same error. And when I open the link in browser it works fine.

Please or to participate in this conversation.