cancel
Showing results for 
Search instead for 
Did you mean: 

REST API - create new product

REST API - create new product

Cannot create new product with rest/V1/products POST method but can update with the same.

How to create a new product?

5 REPLIES 5

Re: REST API - create new product

Hi @RB10100,

 

I guess you've cheked the documentation: http://devdocs.magento.com/swagger/#!/catalogProductRepositoryV1/catalogProductRepositoryV1SavePost

 

Are you sure you are using POST instead of PUT ?

Re: REST API - create new product

Yes I am using POST

Re: REST API - create new product

Hello,

 

you need to use put

 

/V1/products/{sku}

 

$productData = [
    "sku" : "sku-test"
    "name": "Test",
    "price": 100,
    "status": 1
];

Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: REST API - create new product

I am getting {"message":"Invalid product data: %1","parameters":["Invalid attribute set entity type"]} error. Cannot create products.

Re: REST API - create new product


@RB10100 wrote:

I am getting {"message":"Invalid product data: %1","parameters":["Invalid attribute set entity type"]} error. Cannot create products.


 

So do i, pls help

 

Additional, i used the both of PUT and POST and them responded the same error

 

This is the body:

{
  "product": {
    "id": 0,
    "sku": "MS-Champ11",
    "name": "Champ Tee11",
    "attribute_set_id": 9,
    "price": 110,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": null,
    "updated_at": null,
    "weight": 5,
    "extension_attributes": null,
    "product_links": null,
    "options": null,
    "media_gallery_entries": null,
    "tier_prices": null,
    "custom_attributes": [
      {
        "attribute_code": "description",
        "value": "Test Description"
      }
    ]
  },
  "save_options": false
}