06-08-2023 06:01 AM
Hello,
I'm trying to make an api call to add an article (createOrReplaceInventoryItem). I get this error and I don't know what to do...(I think it's related to the form submission... ???)
{"errors":[{"errorId":2004,"domain":"ACCESS","category":"REQUEST","message":"Invalid request","longMessage":"The request has errors. For help, see the documentation for this API."}]}
I don't have a problem using the getInventoryItems method though...
someone can help me ? 😙
$postData = json_encode(array("condition"=>"NEW"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.ebay.com/sell/inventory/v1/inventory_item/tutu");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization:Bearer mytoken','Accept:application/json','Content-Type:application/json','Content-Language:fr-FR'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$result = curl_exec($ch);
curl_close($ch);
08-31-2023 07:16 AM
Hi,
I had the same issue. The problem was the method "POST", use "PUT" instead.
So replace
curl_setopt($ch, CURLOPT_POST, 1);
with
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
and it should work as expected.