Skip to main content
Published: December 04 2014, 2:00:00 AMUpdated: August 29 2022, 3:56:27 PM

 

The below code sample shows how to make an HTTP POST call using node.js to execute GetItem API call.

You need to replace the text "INSERT_YOUR_USER_TOKEN" with your production user token and insert a valid ItemID.

 

var xml = '<?xml version="1.0" encoding="utf-8"?>'+
'<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">'+
'<RequesterCredentials>'+
'<eBayAuthToken>INSERT_YOUR_USER_TOKEN</eBayAuthToken>'+
'</RequesterCredentials>'+
'<DetailLevel>ReturnAll</DetailLevel>'+
'<ItemID>361119561371</ItemID>'+
'</GetItemRequest>';


var https = require('https');

var options = {
host: "api.ebay.com",
path: "/ws/api.dll",
method: "POST",
headers: {
    'X-EBAY-API-COMPATIBILITY-LEVEL': '1235',
    'X-EBAY-API-CALL-NAME': 'GetItem',
    'X-EBAY-API-SITEID':'0',
    'Content-Type' : 'text/xml',
    'Content-Length':xml.length
}
};

var req = https.request(options, function (res)
{
   console.log("statusCode: ", res.statusCode);
   console.log("headers: ", res.headers);

   res.on('data', function (d)
   {
    process.stdout.write(d);

  });

});

req.write(xml);
req.end();

req.on('error', function (e)
{
   console.error('error=======', e);
}
);

 

How well did this answer your question?
Answers others found helpful

Got thoughts? Click the feedback button – your insights help us improve!