Question

$productData = array(
        'sku'               => 'MSD',
        'name'              => 'MSD',
        'visibility'        => 4, /*'catalog',*/
        'type_id'           => 'simple',
        'price'             => 5,
        'status'            => 1,
        'attribute_set_id'  => 4,
        'weight'            => 1,
        'custom_attributes' => array(
            array( 'attribute_code' => 'category_ids', 'value' => ["3"] ),
            array( 'attribute_code' => 'description', 'value' => 'Simple Description' ),
            array( 'attribute_code' => 'short_description', 'value' => 'Simple  Short Description' ),
            ),
    );

and passing data like below

$result = $soapClient->catalogProductRepositoryV1save(array('product' => $productData));

I got this error
Fatal error: Uncaught SoapFault exception: [env:Sender] Invalid product data: %1 in D:\xampp\htdocs\magento214\vendor\zendframework\zend-soap\src\Client.php:1116 Stack trace: #0 D:\xampp\htdocs\magento214\vendor\zendframework\zend-soap\src\Client.php(1116): SoapClient->__soapCall('catalogProductR...', Array, NULL, NULL, Array) #1 D:\xampp\htdocs\magento214\soap5.php(34): Zend\Soap\Client->__call('catalogProductR...', Array) #2 {main} thrown in D:\xampp\htdocs\magento214\vendor\zendframework\zend-soap\src\Client.php on line 1116

Was it helpful?

Solution

Replace attribute_set_id with attributeSetId and type_id with typeId:

$productData = array(
    'sku'               => 'MSD',
    'name'              => 'MSD',
    'visibility'        => 4, /*'catalog',*/
    'typeId'           => 'simple',
    'price'             => 5,
    'status'            => 1,
    'attributeSetId'  => 4,

...
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top