Home
Find the answer to your question
How can I make a call to GetProductSearchResults using the .NET SDK?
How can I make a call to GetProductSearchResults using the .NET SDK?
Here is the sample code for making a call to GetProductSearchResults using the .NET SDK:
using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
usingeBay.Service.Util;
usingeBay.Service.Core.Soap;
namespace SDK3Sample
{
public void GetProductSearchResults()
{
//make the call for a DVD with UPC code
GetProductSearchResultsCall apicall = new GetProductSearchResultsCall(GetContext());
ValType val = new ValType();
val.ValueLiteral = "024543129752";
SearchAttributesType attribute = new SearchAttributesType();
attribute.AttributeID = 25008;
attribute.ValueList = new ValTypeCollection();
attribute.ValueList.Add(val);
ProductSearchType search = new ProductSearchType();
search.SearchAttributes = new SearchAttributesTypeCollection();
search.AttributeSetID = 1177;
search.SearchAttributes.Add(attribute);
ProductSearchTypeCollection searchList = new ProductSearchTypeCollection();
searchList.Add(search);
ProductSearchResultTypeCollection results = apicall.GetProductSearchResults(searchList);
}
public ApiContext GetContext()
{
context = new ApiContext();
//set your credentials
context.ApiCredential.eBayToken = "token";
context.ApiCredential.ApiAccount.Application = "AppID";
context.ApiCredential.ApiAccount.Developer = "DevID";
context.ApiCredential.ApiAccount.Certificate = "CertID";
context.SoapApiServerUrl = ""url";
//set the version
context.Version = "459";
//set the logging
string logFile = "LogFile.txt";
context.ApiLogManager = new ApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new FileLogger(logFile, true, true, true));
context.ApiLogManager.EnableLogging = true;
return context;
}
}
Here is the corresponding SOAP request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<RequesterCredentials xmlns="urn:ebay:apis:eBLBaseComponents">
<eBayAuthToken>******</eBayAuthToken>
</RequesterCredentials>
</soap:Header>
<soap:Body>
<GetProductSearchResultsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<Version>459</Version>
<ProductSearch>
<AttributeSetID>1177</AttributeSetID>
<SearchAttributes>
<AttributeID>25008</AttributeID>
<ValueList>
<ValueLiteral>024543129752</ValueLiteral>
</ValueList>
</SearchAttributes>
</ProductSearch>
</GetProductSearchResultsRequest>
</soap:Body>
</soap:Envelope>