Magento REST api

I am trying to use magento rest api for clients. But when I authenticate the application, it gives me the following error.

Invalid auth/bad request (got a 500, expected HTTP/1.1 20X or a redirect) Service temporary unavailable 

I am trying to retrieve a collection of products for a customer role.

 $oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/xml')); 

The line excludes the code.

Any help would be appreciated.

+7
rest php oauth magento
source share
2 answers

Have you tried to add an Accept header to your request? I ran into the same issue with the Magento API, tested it and found that the PHP OAuth client does not send an accept header by default. So try the following:

 $oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/xml', 'Accept' => 'application/xml')); 

or

 $oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/xml', 'Accept' => '*/*')); 

You can view additional information about the exception using the following when configuring the client:

 $oauthClient->enableDebug(); 

... and then look at debugging with:

 $oauthClient->debugInfo 

or

 $oauthClient->getLastResponse 

Other methods are described here:

http://www.php.net/manual/en/class.oauth.php

+16
source share

I used $oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => '*/*')); which works great.

+2
source share

All Articles