Skip to main content
Published: December 23 2011, 2:58:00 PMUpdated: August 24 2022, 9:04:52 PM

How can I make a simple GetItem call using the .NET SDK (C#)?

Summary
 

GetItem C# sample



Detailed Description
This sample is using Microsoft Visual Studio 2010, eBay .NET SDK 

Requirements:

After opening a C# project,

-  Add a reference to eBay.Service dll

-  Make sure Target Framework is NOT set to .NET Framework Client Profile

 

1.  Add these namespaces

using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Core.Soap;

2.  Code Sample (This sample was in a windows form project in a button click):

           

/*
© 2011-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/

            ApiContext oContext = new ApiContext();

            //set the AuthToken
            oContext.ApiCredential.eBayToken = "xxx";

            //set the endpoint (sandbox) use https://api.ebay.com/wsapi for production
            oContext.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";

            //set the Site of the Context
            oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US;

            //the WSDL Version used for this SDK build
            oContext.Version = "1235";

            //very important, let's setup the logging
            ApiLogManager oLogManager = new ApiLogManager();
            oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetItem.log", true, true, true));
            oLogManager.EnableLogging = true;
            oContext.ApiLogManager = oLogManager;
            

            GetItemCall oGetItemCall = new GetItemCall(oContext);

            //' set the Version used in the call
            oGetItemCall.Version = oContext.Version;

            //' set the Site of the call
            oGetItemCall.Site = oContext.Site;

            //' enable the compression feature
            oGetItemCall.EnableCompression = true;

            oGetItemCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
           
            oGetItemCall.ItemID = "#";

            oGetItemCall.GetItem(oGetItemCall.ItemID);

            //Add code to filter response here.........



Additional Resources

 

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