0

How can we call Web API in a custom module?

I have a third party module, in which they are sending a request with API calls. I have custom functionality where I have to redirect my page to that Web API link, so everything works smoothly

Can anyone here tell, how we can do that in Magento2? Some step by step guide?

Thanks!

  • what is your exact requirement ? You need just to redirect on a link ? Means say you have a controller from there you want to redirect on a link or call an API ? – Narendra Vyas Mar 29 '19 at 10:36
  • Ya, If i use the default module they are using this link ttp://m2.example.com/rest/no/V1/guest-carts/uDa31URAYN4ZGmrgPlxEHTHJdrSLR34Z/test/checkout/authorize. – Daniel_12 Mar 29 '19 at 10:39
  • I have one button where I want to redirect to this url – Daniel_12 Mar 29 '19 at 10:40
  • See my answer. If it help you – Narendra Vyas Mar 29 '19 at 10:40
-1

you can call to external API from inside Magento 2. Just use \Magento\Framework\HTTP\ZendClient inside your class.

Read more here.

A sample project here in Github

  • \Magento\Framework\HTTP\Adapter\Curl should be used – Philipp Sander Mar 29 '19 at 10:59
  • can you give me pseudocode how to use that one – Daniel_12 Mar 29 '19 at 11:10

Your Answer

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

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