1

Any once please help me out for overwrite the REST api in magento 2.3 please describe with example.

2 Answers 2

1

You need to create a webapi.xml file under etc folder within your custom module

webapi.xml

<?xml version="1.0"?>

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
  <route url="/V1/customers" method="POST">
    <service class="VendorName\ModuleName\Api\AccountManagementInterface" method="createAccount"/>
    <resources>
        <resource ref="anonymous"/>
    </resources>
  </route>
</routes>

You need to define interfaces same as AccountManagementInterface of customer module. I hope it will work. Let me know if you need further help :)

3
  • Thanks For your Reply, It's show dependency error like "Class ABC\\Customer\\Model\\EmailNotificationInterface does not exist" & once i copy that file from core to my module it's work so this is a right way to do that? Mar 29, 2019 at 5:57
  • what do you want to achieve by overriding endpoint? Mar 29, 2019 at 6:31
  • I have created some custom attribute so i would like to get in response that's why i need to overwrite the above API. Can you please help me to solve this "EmailNotificationInterface does not exist" error? May 13, 2019 at 5:38
1

If you want just add some custom data to response, there is no reason to do some overrides. You can archive this with use of extension attributes there I provided an example (about quote item, but for Customer idea should be the same). If you don't know about extension attributes there a good starting point.

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.