0

So I am sending below-mentioned XML payload to Magento's API: https://magento2.jitterbit.com/rest/all/V1/products/{sku}/links

XML Payload:

<items>
    <link_type>related</link_type>
    <linked_product_sku>ns120240</linked_product_sku>
    <linked_product_type>simple</linked_product_type>
    <position>0</position>
    <sku>ns120243</sku>
</items>

and the error I'm facing is as follows Error:

    '{
    "message": "%fieldName is a required field.",
    "parameters": {
        "fieldName": "linkType"
    },
    "trace": "#0 /home/jitterbi/public_html/magento2/vendor/magento/module-catalog/Model/ProductLink/Management.php(75): Magento\\Framework\\Exception\\InputException::requiredField('linkType')\n#1 [internal function]: Magento\\Catalog\\Model\\ProductLink\\Management->setProductLinks('ns120240', Array)\n#2 /home/jitterbi/public_html/magento2/vendor/magento/module-webapi/Controller/Rest.php(307): call_user_func_array(Array, Array)\n#3 /home/jitterbi/public_html/magento2/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#4 /home/jitterbi/public_html/magento2/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 /home/jitterbi/public_html/magento2/vendor/magento/framework/App/Http.php(136): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#6 /home/jitterbi/public_html/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#7 /home/jitterbi/public_html/magento2/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#8 {main}"
}'

It is working fine (returning true as expected) if I change the single element XML payload to multiple element payload as follows:

<root>
<items>
    <link_type>related</link_type>
    <linked_product_sku>ns120240</linked_product_sku>
    <linked_product_type>simple</linked_product_type>
    <position>0</position>
    <sku>ns120243</sku>
</items>
<items>
    <link_type>related</link_type>
    <linked_product_sku>ns120240</linked_product_sku>
    <linked_product_type>simple</linked_product_type>
    <position>0</position>
    <sku>ns120243</sku>
</items>
</root>

So, what if I just want to send 1 element, what should I do? For more reference please follow: https://github.com/stleary/JSON-java/issues/330

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.