Hallo Ihr,
ich möchte meine Artikel aus der Warenwirtschaft (Bestände und Preise) über die REST - API updaten. Das ganze funktioniert auch wunderbar wenn ich jeden Artikel einzeln übergebe.
Was ich aus Laufzeitgründen jedoch eigentlich möchte ist, dass ich mir ein JSON Array (Alle Artikel) zusammenbaue und diesen dann übertrage. Das Zusammenstellen des JSON habe ich gelöst jedoch bekomme ich immer eine Fehlermeldung wenn ich das JSON Array hochladen möchte.
RestRequest requestput = new RestRequest(“variants”, Method.PUT);
requestput.AddJsonBody(variant); //Variant ist das Objekt mit den gesamten Artikeln
var updateArt = client.Execute(requestput);
“StatusCode: OK, Content-Type: application/json, Content-Length: -1)”
"{\"success\":true,\"data\":{\"data\":{\"success\":false,\"message\":\"\",\"trace\":\"#0 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/Api\\/Resource\\/Resource.php(527): Shopware\\\\Components\\\\Api\\\\Resource\\\\Variant->create(Array)\\n#1 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Controllers\\/Api\\/Rest.php(78): Shopware\\\\Components\\\\Api\\\\Resource\\\\Resource->batch(Array)\\n#2 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Action.php(158): Shopware_Controllers_Api_Rest->batchAction()\\n#3 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Dispatcher\\/Default.php(523): Enlight_Controller_Action->dispatch('batchAction')\\n#4 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Front.php(226): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))\\n#5 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Kernel.php(153): Enlight_Controller_Front->dispatch()\\n#6 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(492): Shopware\\\\Kernel->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#7 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(255): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true, NULL)\\n#8 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(263): Shopware\\\\Components\\\\HttpCache\\\\AppCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#9 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(280): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->pass(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#10 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(133): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#11 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(209): Shopware\\\\Components\\\\HttpCache\\\\AppCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#12 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(114): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#13 \\/scaxflvs\\/www.SHOPURL.de\\/shopware.php(101): Shopware\\\\Components\\\\HttpCache\\\\AppCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request))\\n#14 {main}\"},\"total\":{\"success\":false,\"message\":\"\",\"trace\":\"#0 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/Api\\/Resource\\/Resource.php(527): Shopware\\\\Components\\\\Api\\\\Resource\\\\Variant->create(0)\\n#1 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Controllers\\/Api\\/Rest.php(78): Shopware\\\\Components\\\\Api\\\\Resource\\\\Resource->batch(Array)\\n#2 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Action.php(158): Shopware_Controllers_Api_Rest->batchAction()\\n#3 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Dispatcher\\/Default.php(523): Enlight_Controller_Action->dispatch('batchAction')\\n#4 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Front.php(226): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))\\n#5 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Kernel.php(153): Enlight_Controller_Front->dispatch()\\n#6 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(492): Shopware\\\\Kernel->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#7 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(255): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true, NULL)\\n#8 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(263): Shopware\\\\Components\\\\HttpCache\\\\AppCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#9 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(280): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->pass(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#10 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(133): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#11 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(209): Shopware\\\\Components\\\\HttpCache\\\\AppCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#12 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(114): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#13 \\/scaxflvs\\/www.SHOPURL.de\\/shopware.php(101): Shopware\\\\Components\\\\HttpCache\\\\AppCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request))\\n#14 {main}\"},\"success\":{\"success\":false,\"message\":\"\",\"trace\":\"#0 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/Api\\/Resource\\/Resource.php(527): Shopware\\\\Components\\\\Api\\\\Resource\\\\Variant->create(false)\\n#1 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Controllers\\/Api\\/Rest.php(78): Shopware\\\\Components\\\\Api\\\\Resource\\\\Resource->batch(Array)\\n#2 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Action.php(158): Shopware_Controllers_Api_Rest->batchAction()\\n#3 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Dispatcher\\/Default.php(523): Enlight_Controller_Action->dispatch('batchAction')\\n#4 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Library\\/Enlight\\/Controller\\/Front.php(226): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))\\n#5 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Kernel.php(153): Enlight_Controller_Front->dispatch()\\n#6 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(492): Shopware\\\\Kernel->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#7 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(255): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true, NULL)\\n#8 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(263): Shopware\\\\Components\\\\HttpCache\\\\AppCache->forward(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#9 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(280): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->pass(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#10 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(133): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#11 \\/scaxflvs\\/www.SHOPURL.de\\/vendor\\/symfony\\/http-kernel\\/HttpCache\\/HttpCache.php(209): Shopware\\\\Components\\\\HttpCache\\\\AppCache->invalidate(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), true)\\n#12 \\/scaxflvs\\/www.SHOPURL.de\\/engine\\/Shopware\\/Components\\/HttpCache\\/AppCache.php(114): Symfony\\\\Component\\\\HttpKernel\\\\HttpCache\\\\HttpCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request), 1, true)\\n#13 \\/scaxflvs\\/www.SHOPURL.de\\/shopware.php(101): Shopware\\\\Components\\\\HttpCache\\\\AppCache->handle(Object(Symfony\\\\Component\\\\HttpFoundation\\\\Request))\\n#14 {main}\"}}}"