Using the code below to get 3rd party API

    $uri = $baseUri . '/area/' . $areaId . '.geojson?api_key=' . $mapAPIkey;

    $client = Craft::createGuzzleClient();
    $response= $client->request('GET',  $uri);
    $data = $response->getBody();
    return $data;

Getting error

Class GuzzleHttp\Psr7\Response contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Psr\Http\Message\RequestInterface::getRequestTarget, Psr\Http\Message\RequestInterface::withRequestTarget, Psr\Http\Message\RequestInterface::getMethod, ...)

What is wrong? Ive been through half a dozen other plugins that use guzzle like this and they seem to be ok

  • What does your composer.json say – which version of guzzlehttp/guzzle are you using?
    – MoritzLost
    Sep 29 at 10:17
  • Plugin composer doesn't have a require guzzle. I though it was native to craft? Do I need to : use GuzzleHttp;
    – joomkit
    Sep 30 at 11:05
  • Guzzle is required by Craft, though Craft's composer.json allows both Guzzle 6 and Guzzle 7. If you're using Guzzle in your own code, you should add it to your own dependencies. Try requiring version 7 explicitly, maybe you've gotten version 6 for some reason and there's something going wrong there: composer require guzzlehttp/guzzle:^7.3
    – MoritzLost
    Sep 30 at 11:55
  • Problem seems to have resolved itself "guzzlehttp/guzzle": "^6.5.5|^7.2.0" Thanks for the reply
    – joomkit
    Oct 3 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.