cancel
Showing results for 
Search instead for 
Did you mean: 

Create new endpoint in the API

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

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

Create new endpoint in the API

Hi everybody,

 

I'm currently working on an headless eCommerce website, whose back-end is Magento 2.3.

 

In order to fullfill some custom needs, I have to enhance the provided API and add new endpoints to it. 

 

Though this kind of need seems pretty usual to me, I didn't read anything about this subject in the Magento API documentation.

 

Any help would be greatly appreciated!

 

Thanks

1 REPLY 1

Re: Create new endpoint in the API

Hello @david_iux ,

 

To create custom API, Please follow this blog https://webkul.com/blog/magento2-custom-rest-api/

You can refer below link for Magento 2.x version. http://devdocs.magento.com/swagger/index_20.html#/

I have used below body for creating customers through Rest Api and it worked properly.

Url : http://www.xxxxxxxx.com/rest/V1/customers

Type: POST

Content-Type : application/json

payload Data:

{
     "customer": {
         "email": "abc@gmail.com",
         "firstname": "Abc",
         "lastname": "Xyz"   

     },
     "password": "Abc@123456"
  }

Response:

{
    "id": 4,
    "group_id": 1,
    "created_at": "2017-01-27 18:35:48",
    "updated_at": "2017-01-27 18:35:48",
    "created_in": "Default Store View",
    "email": "abc@gmail.com",
    "firstname": "Abc",
    "lastname": "Xyz",
    "store_id": 1,
    "website_id": 1,
    "addresses": [],
    "disable_auto_group_change": 0
}

Call through postman see example in attachment:

zWBNQ.png

 

--

If my answer is useful, please Accept as Solution & give Kudos