cancel
Showing results for 
Search instead for 
Did you mean: 

custom webapi routing

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

custom webapi routing

Hi

 

I'm writing a webservice as part of a hosted payment page solution for magento2

I need the web service to be called as part of the checkout process, after placeOrder.

 

I'm having problems getting control of the routing.

My initial url was within cart  (rest/default/V1/carts/mine/myservice) , but that led to problems with the forced parameter card_id, and the fact the cart is cleared by placeOrder.

 

So I think I need the url to be in my own space, like rest/default/V1/hostedservice/myservice

 

I can't get this url to have a recognised route.

I've configured webapi.xml, the interface that implements the method to be called, and the corresponding class and method.

I'm unclear whether routes.xml should play a role in the solution...

 

I read at https://devdocs.magento.com/guides/v2.3/extension-dev-guide/routing.html that the url should have the format
<store-url>/<store-code>/<front-name>/<controller-name>/<action-name>

This pattern doesn't seem to match the url pattern generated client side by module-checkout/view/frontend/web/js/model/url-builder.js
Although my new url does not mention carts, somehow the stack ends up at
/var/www/html/magento/generated/code/Magento/Quote/Model/Webapi/ParamOverriderCartId/Proxy.php
which causes a 404
I'm about to start debugging /var/www/html/magento/vendor/magento/module-webapi/Controller/Rest.php
Hopefully someone can save me from that pain.
Thanks
Martin

 

1 REPLY 1

Re: custom webapi routing

The problem was I had left this configuration in webapi.xml...

        <data>
            <parameter name="cartId" force="true">%cart_id%</parameter>
        </data>