Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Api Put Gives 404 Rate Topic   - - - - -

 
  • mark89769
  • Junior Member
  • Trial users
  • Join Date: 18-Mar 11
  • 13 posts

Posted 24 July 2015 - 06:10 AM #1

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.

 
  • mark89769
  • Junior Member
  • Trial users
  • Join Date: 18-Mar 11
  • 13 posts

Posted 24 July 2015 - 06:39 AM #2

Found the solution,

Open "/etc/httpd/conf/httpd.conf" and look for:
<Directory /home/*>
AllowOverride All
Options -MultiViews -Indexes FollowSymlinks IncludesNoExec +Includes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif][size=3]Then just add PUT (and maybe DELETE if you want) after PROPFIND[/size][/font][/color]


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11384 posts

Posted 24 July 2015 - 07:37 PM #3

What did you change? Assume you had to add 'PUT' to the allow clause.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • mark89769
  • Junior Member
  • Trial users
  • Join Date: 18-Mar 11
  • 13 posts

Posted 24 July 2015 - 09:43 PM #4

What did you change? Assume you had to add 'PUT' to the allow clause.


Yes. added PUT and DELETE after PROPFIND.