Skip to content

Randomly receiving this error (Magic request methods require a URI and optional options array) In magento 2.4.5-p1

Below error occurs randomly while navigating to the checkout page

Magic request methods require a URI and optional options array in vendor/magento/framework/Webapi/ErrorProcessor.php:208
    Stack trace:
    #0 vendor/magento/framework/Webapi/ErrorProcessor.php(153): MagentoFrameworkWebapiErrorProcessor->_critical(Object(GuzzleHttpExceptionInvalidArgumentException))
    #1 vendor/magento/module-webapi/Controller/Rest.php(197): MagentoFrameworkWebapiErrorProcessor->maskException(Object(GuzzleHttpExceptionInvalidArgumentException))
    #2 vendor/magento/framework/Interception/Interceptor.php(58): MagentoWebapiControllerRest->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #3 vendor/magento/framework/Interception/Interceptor.php(138): MagentoWebapiControllerRestInterceptor->___callParent('dispatch', Array)
    #4 vendor/fastly/magento2/Model/FrontControllerPlugin.php(135): MagentoWebapiControllerRestInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
    #5 vendor/magento/framework/Interception/Interceptor.php(135): FastlyCdnModelFrontControllerPlugin->aroundDispatch(Object(MagentoWebapiControllerRestInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #6 vendor/magento/module-company/Plugin/Webapi/Controller/RestPlugin.php(84): MagentoWebapiControllerRestInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
    #7 vendor/magento/framework/Interception/Interceptor.php(135): MagentoCompanyPluginWebapiControllerRestPlugin->aroundDispatch(Object(MagentoWebapiControllerRestInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #8 vendor/magento/framework/Interception/Interceptor.php(153): MagentoWebapiControllerRestInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
    #9 generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): MagentoWebapiControllerRestInterceptor->___callPlugins('dispatch', Array, Array)
    #10 vendor/magento/framework/App/Http.php(116): MagentoWebapiControllerRestInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #11 vendor/magento/framework/App/Bootstrap.php(264): MagentoFrameworkAppHttp->launch()
    #12 pub/index.php(30): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
    #13 {main}

I’ve used guzzlehttp in my custom code like below. it will call external API in checkout page

     $client = $this->clientFactory->create([
                'config' => [
                    'base_uri' => $baseUrl
                ]
            ]);
     try {
            $response = $client->post(
                $uriEndpoint,
                $params
            );
        } catch (GuzzleException $exception) {
            /** @var Response $response */
            $response = $this->responseFactory->create([
                'status' => $exception->getCode(),
                'reason' => $exception->getMessage()
            ]);
        }

        return $response;

Any idea what I am missing here?