6

How can i create the base url for magento.

I have this error when i hit the url to get the order can some help me to find out the solution. I am using oauth authentication

{
  "message": "Request does not match any route.",
  "trace": null
}

url : http://sca.followthetiger.com/api/rest/order and pass the consumer key and all in header.

2
  • You can create Rest API module by following this tutorial. inchoo Also, apply this command after creating the module: php bin/magento setup:upgrade Hope this help. May 21, 2017 at 11:01
  • This doesnt answer the question asked.
    – John
    Mar 26, 2019 at 12:47

3 Answers 3

4

Using my localhost site url with https:// instead of http:// did the magic for me:

So: https://magento2.local/rest/V1/integration/customer/token/ Passing as body :

{"username":"[email protected]", "password":"customerpassword"}

2
2

You are using the wrong URL. Instead of

http://sca.followthetiger.com/api/rest/order

you should use

http://sca.followthetiger.com/api/rest/V1/orders/:order_id

1

This issue appeared when I tried to automatically apply a coupon code at checkout with a button click. I have created a mixin from the Magento_SalesRule/js/view/payment/discount JS file, and simply targeted the coupon field and entered the code via jQuery. After executing this.apply(), the error appeared.

What I didn't realise was that the code was also handled by Knockout, and so the field had to be updated via this.couponCode("theCode"), then it would work.

So to answer your question, please ensure that the URL fully matches what the API expects, which includes any parameters within the URL itself. For coupon codes, the URL template is /V1/guest-carts/:cartId/coupons/:couponCode, but as the browser was sending "V1/guest-carts/abcdefghijklmnopqrstuvwxyz123456/coupons/" (notice the missing coupon code at the end of the URL), it deemed it an invalid route.

You can view all the available API routes via all of the webapi.xml files. For retrieving an order via an ID, use /V1/orders/:id, which is specified in vendor/magento/module-sales/etc/webapi.xml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.