Hi!,
I'm trying my hands in rest api for fetching some information, now i want to put some information,
i'm looking for the solution to Create a new product in magento usnig rest api,
if some one is know then please tell me the procedure and steps to do that.
Thank you in advance.
Please try it:
Step1. Generate admin token: I am using token for authorization, so create an admin token using this URL Http://{baseurl}/rest/V1/integration/admin/token
Step2. Add product : For adding the product, I am using following URL http://magentogit.com/rest/V1/products/{SKU} , this is magento2 default API using put method. For example :
http://baseurl/rest/V1/products/B201-SKU
header:
Content-Type - application/json
Authorization - Bearer token
Body:
{
"product": {
"sku": "B201-SKU",
"name": "B202",
"price": 30.00,
"status": 1,
"type_id": "simple",
"attribute_set_id":4,
"weight": 1
}
}
Please Use http://magentogit.com/rest/V1/products/ instead of http://magentogit.com/rest/V1/products/{SKU}
For example :
http://baseurl/rest/V1/products/
@OST Agencywrote:Please try it:
Step1. Generate admin token: I am using token for authorization, so create an admin token using this URL Http://{baseurl}/rest/V1/integration/admin/token
Step2. Add product : For adding the product, I am using following URL http://magentogit.com/rest/V1/products/ , this is magento2 default API using put method. For example :
http://baseurl/rest/V1/products/
header:
Content-Type - application/json
Authorization - Bearer token
Body:
{
"product": {
"sku": "B201-SKU",
"name": "B202",
"price": 30.00,
"status": 1,
"type_id": "simple",
"attribute_set_id":4,
"weight": 1
}
}