davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
349 stars 341 forks source link

Working with BulkDataExchangeService throws Guzzle [Guzzle\Http\Exception\ServerErrorResponseException] Server error response [status code] 500 #63

Closed marcelkussin closed 7 years ago

marcelkussin commented 7 years ago

Hello,

im using your Library since several months but now suddenly i get a Response and i dont know how to debug it.

Exception:

[Guzzle\Http\Exception\ServerErrorResponseException]        
  Server error response                                       
  [status code] 500                                           
  [reason phrase] Internal Server Error                       
  [url] https://webservices.ebay.com/BulkDataExchangeService  

Code:

$exchangeService = new BulkDataExchange\Services\BulkDataExchangeService(array(
                        'authToken' => $config[$config['current']]['usertoken'],
                        'sandbox' => $config['current'] == 'sandbox'
                    ));
                    $transferService = new FileTransfer\Services\FileTransferService(array(
                        'authToken' => $config[$config['current']]['usertoken'],
                        'sandbox' => $config['current'] == 'sandbox'
                    ));
                    $merchantDataService = new MerchantData\Services\MerchantDataService();

$request = new BulkDataExchange\Types\GetJobsRequest();
                    $response = $exchangeService->getJobs($request); -> throws exception
davidtsadler commented 7 years ago

Looking at the exception is appears that you are connecting to the production server https://webservices.ebay.com/BulkDataExchangeService. Make sure that the credentials that you are passing to the SDK are correct for that environment as passing the wrong ones, i.e. your sandbox credentials, can trigger the eBay error.

marcelkussin commented 7 years ago

im sending the right ones and it worked with them until yesterday

marcelkussin commented 7 years ago

forget it... it Expired yesterday and that was the only problem... I wish eBay would send a better Error to catch that exception

davidtsadler commented 7 years ago

Interesting to know that it also triggers on an expired token as I've never come across that.

davidtsadler commented 7 years ago

I may look at seeing if I should have the SDK not throw an exception for a 500 status code. It would allow people to obtain the error message from eBay.

davidtsadler commented 7 years ago

It is possible to catch the exception thrown by Guzzle. It's a bit hacky but it does show the XML response from eBay which can help tracking down the cause of the error.

try
{
    $response = $exchangeService->getJobs($request);
}
catch (GuzzleHttp\Exception\RequestException $e) {
    if ($e->hasResponse()) {
        echo $e->getResponse()->getBody()->getContents();
    }    
    exit();
}