4

How can I call eBay and request it to return search results array?

This is what I came up with so far:

string endpoint = "https://api.ebay.com/wsapi";
string siteId = "0";
string appId = "*";     // use your app ID
string devId = "*";     // use your dev ID
string certId = "*";   // use your cert ID
string version = "405";

string requestURL = endpoint
+ "?callname=FindProducts"
+ "&siteid=" + siteId
+ "&appid=" + appId
+ "&version=" + version
+ "&routing=default"
+ "&AvailableItemsOnly=true"
+ "&QueryKeywords=nvidia"
+ "&itemFilter(0).name=ListingType"
+ "&itemFilter(0).value(0)=FixedPrice"
+ "&itemFilter(0).value(1)=Auction"
+ "&CategoryID=27386";

How can I wrap it into request and get a response in some-sort of data-structure? I have gotten the SDK.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Andrew
  • 7,619
  • 13
  • 63
  • 117
  • 1
    They have an SDK .NET wrapper for you so you don't have to handle this all manually: http://developer.ebay.com/DevZone/WindowsSDK/docs/Getting%20Started/GettingStartedGuide.html. Have you tried that? – mellamokb Jun 01 '12 at 21:52
  • could you give me an example that could help me with my problem? – Andrew Jun 01 '12 at 22:15
  • See the example here: http://developer.ebay.com/DevZone/WindowsSDK/docs/Getting%20Started/HowTo/MakingACall.html#Call. From there, I believe there will be a method called `FindProducts` that you can call with the parameters you are manually putting into a string. You shouldn't have to mess with building querystrings, request url's, SOAP, responses, etc. – mellamokb Jun 01 '12 at 22:24
  • I tried to create 'FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();' but getting messager 'Error 1 The type or namespace name 'FindItemsByKeywordsRequest' could not be found (are you missing a using directive or an assembly reference?)' but the references are there... :\ – Andrew Jun 02 '12 at 06:12

1 Answers1

4

I needed to use the eBay finding API;

    public GetItemCall getItemDataFromEbay(String itemId)
    {
        ApiContext oContext = new ApiContext();
        oContext.ApiCredential.ApiAccount.Developer = ""; // use your dev ID
        oContext.ApiCredential.ApiAccount.Application = ""; // use your app ID
        oContext.ApiCredential.ApiAccount.Certificate = ""; // use your cert ID
        oContext.ApiCredential.eBayToken = "";            //set the AuthToken

        //set the endpoint (sandbox) use https://api.ebay.com/wsapi for production
        oContext.SoapApiServerUrl = "https://api.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 = "735";

        //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(eBay.Service.Core.Soap.DetailLevelCodeType.ReturnAll);
        oGetItemCall.ItemID = itemId;
        try
        {
            oGetItemCall.GetItem(oGetItemCall.ItemID);
        }
        catch (Exception E)
        {
            Console.Write(E.ToString());
            oGetItemCall.GetItem(itemId);
        }
        GC.Collect();
        return oGetItemCall;
    }
Andrew
  • 7,619
  • 13
  • 63
  • 117