7

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

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

I am trying to fetch product collection for customer role.

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

The line of code throws exception.

Any help will be appreciated.

2 Answers 2

16

Have you tried adding an "Accept" header to your request? I ran into the same problem with the Magento API, tested it and found that the PHP OAuth client doesn't send any accept header by default. So try the following instead:

$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 more info about the exception by using the following when you set up the client:

$oauthClient->enableDebug();

...and then looking at the debug with:

$oauthClient->debugInfo

or

$oauthClient->getLastResponse

The other methods are documented here:

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

Sign up to request clarification or add additional context in comments.

2 Comments

$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/xml', 'Accept' => '/')); This works, and solved the problem..
Works for me too Hasina
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.