cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

createOrReplaceInventoryItemInventory api curl php

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);

 

Message 1 of 2
latest reply
1 REPLY 1

createOrReplaceInventoryItemInventory api curl php

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.

Message 2 of 2
latest reply