Magento 2 – Add Product with Description via REST API

apimagento2rest

Apologies if this is a silly question, I'm sure it must be but I just can't seem to figure out how you are supposed to add a product's description via REST.

The REST API docs at http://devdocs.magento.com/swagger/index_20.html under the catalogProductRepositoryV1 list all the the available fields but description is not there.

Can someone advise which resource the product's description is managed through?

Best Answer

We need to add custom_attributes:

$productData = [
        'attribute_set_id'  => 4,
        "type_id": "simple",
        "sku": "test-SKU",
        "name": "Test",
        "price": 100,
        "status": 1,
        'custom_attributes' => [
                ['attribute_code' => 'description', 'value' => 'Test Description' ],
                ['attribute_code' => 'short_description', 'value' => 'Test Short Description' ],
            ]
    ];

Payload:

{
    "product": {
        "attribute_set_id": 4,
        "type_id": "simple",
        "sku": "test-SKU",
        "name": "Test",
        "price": 100,
        "status": 1,
        "custom_attributes": {
            "description": "Test Description",
            "short_description": "Test Short Description"
        }
    }
}
Related Topic