Jump to content

 

mark89769

Member Since 18 Mar 2011
Offline Last Active Jul 25 2015 06:17 AM
-----

Topics I've Started

Api Put Gives 404

24 July 2015 - 06:10 AM

Hi,

I'm trying to change a product name with the API. When I set the custom request as PUT, the response is always 404. What am I doing wrong?

$ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $api_url.'products/2');
	    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
	    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
	    curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($ch, CURLOPT_USERPWD, "$user_login:$api_key");
	    $response  = curl_exec($ch);
	    curl_close($ch);

ProductID 2 exists and with a GET the reponse the reponse is ok.