When I tried to retreive all categories through the eBay Trading API with the method getCategories
, I got this error:
FailureApplication name invalid.API application “222277”
invalid.127Error222277RequestError895E895_INTL_APICATALOG_17257399_R1
The header used is:
$headers = array(
'Content-Type:text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL: 895',
'X-EBAY-API-DEV-NAME: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'X-EBAY-API-APP-NAME: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx',
'X-EBAY-API-CERT-NAME: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
'X-EBAY-API-CALL-NAME: GetCategories',
'X-EBAY-API-SITEID: 0'
);
The XML postfields:
$body = <<<BODY
<?xml version="1.0" encoding="utf-8"?>
<GetCategoriesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>auth token......</eBayAuthToken>
</RequesterCredentials>
<CategorySiteID>0</CategorySiteID>
<DetailLevel>ReturnAll</DetailLevel>
</GetCategoriesRequest>
BODY;
and curl code:
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $endpoint);
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $body);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection);
curl_close($connection);
2
Answers
Ebay provides an API test tool.
It will pre-populate your credentials and let you make a test call.
Test Tool
This will help you debug any errors that you might get.
Unfortunately, eBay recently discontinued their API test tool. However, there are some 3rd party ones that may suffice.
For your issue, I recommend using the simpler Shopping API call called GetCategoryInfo. You don’t need to POST your request or send any HTTP headers, and you can build your entire call into 1 URL/REST/GET request. This makes debugging much easier.
Either way you go about it, I don’t think you can retrieve all of eBay’s categories with 1 request. Instead, plan to loop through the category tree at each level, collecting the child category names and IDs.