Search code examples
node.jsebay-api

ebay api using nodeJs gives error "Unable to create xml stream reader for JSON: payload format incorrect or payload is empty"


I am trying to get list product with a keyword using ebay api maintained Here

using following code

var params = {};

params.keywords = ["Canon"];
params.outputSelector = [ 'AspectHistogram' ];

params['paginationInput.entriesPerPage'] = 10;


var filters = {};

filters.itemFilter = [
    new ebay.ItemFilter("FreeShippingOnly", true)
];

filters.domainFilter = [
    new ebay.ItemFilter("domainName", "Digital_Cameras")
];


ebay.ebayApiGetRequest({
        serviceName: 'FindingService',
        opType: 'findItemsByKeywords',
        appId: '*********************',      // FILL IN YOUR OWN APP KEY, GET ONE HERE: https://publisher.ebaypartnernetwork.com/PublisherToolsAPI
        params: params,
        filters: filters,
        parser: ebay.parseItemsFromResponse    // (default)
    },
    // gets all the items together in a merged array
    function itemsCallback(error, items) {
        if (error) throw error;

        console.log('Found', items.length, 'items');

        for (var i = 0; i < items.length; i++) {
            console.log('- ' + items[i].title);
        }
    }
);

Which throws following error when called

Error: Bad response status code 500 
{
  "errorMessage":[{
  "error":[{"errorId":["5006"],
  "domain":["CoreRuntime"],
  "severity":["Error"],
  "category":["System"],
  "message":["Unable to create xml stream reader for JSON: payload format incorrect or payload is empty"],
  "subdomain":["Comm_Recv"],
  "parameter":[{"@name":"Param1","__value__":"JSON"}]}]
}]
}

Solution

  • Show the code of api import. May be a problem there... try

    var ebay = require('ebay-api');