cancel
Showing results for 
Search instead for 
Did you mean: 

How to create new product using REST API in Magento 2

How to create new product using REST API in Magento 2

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.

3 REPLIES 3

Re: How to create new product using REST API in Magento 2

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

 }

}

OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions

Re: How to create new product using REST API in Magento 2

Please Use http://magentogit.com/rest/V1/products/ instead of http://magentogit.com/rest/V1/products/{SKU}

For example :

http://baseurl/rest/V1/products/

 

Re: How to create new product using REST API in Magento 2


@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

 }

}