I Have custom table name like test_table and it contains fields like name, number and city.
I want to insert data using Magento 2 REST API.
Please Let me know if you have any idea?
magento2rest api
I Have custom table name like test_table and it contains fields like name, number and city.
I want to insert data using Magento 2 REST API.
Please Let me know if you have any idea?
Best Answer
Step 1:- Create a module Stackexchange_Test using silk software module creator Click here to create a module
Step2 :- create a install script using below script in the below path app/code/Stackexchange/Test/Setup/InstallSchema.php
Now steps to create a api
Step 3: app/code/Stackexchange/Test/etc/webapi.xml
Step 4: app/code/Stackexchange/Test/etc/di.xml
Step 5: app/code/Stackexchange/Test/Api/TestInterface.php
Step 6: app/code/Stackexchange/Test/Model/Test.php
Step 7:- While do the changes please use di compile and clear cache and page cache and deploy the same
Step 8: Please post the data using postman app as shown in the below screenshot.
Note: Header section [{"key":"Content-Type","value":"application/json","description":""}]
Body section:-
Step 9: check the data base table 'test_table'