1

我正在尝试使用 FindCompletedItemRequest 查询 eBay,但服务器返回 null

这是代码

public static CustomFindingService FindingService(){
CustomFindingService findingService;
log.InfoFormat("Connect to Ebay: START");

findingService = new CustomFindingService("XXXXXX-XXXX-XXXXX-XXXXX-XXXXX");
findingService.UseDefaultCredentials = true;

log.InfoFormat("Connect to Ebay: SUCCESS");
return findingService;
   }

var fcir = new FindCompletedItemsRequest {keywords = "5mp", categoryId =new string[] {"31388"}}; // 31388 is digital cameras
var l = FindingService().findCompletedItems(fcir); 

我尝试删除 categoryId 和/切换关键字似乎没有任何帮助。调试向我表明,它正在 ping 服务器,只是服务器返回 null。

任何帮助,将不胜感激。

4

1 回答 1

3

我建议您提供CustomFindingService的代码。无论如何,我可以尝试解决您的问题。

findingService = new CustomFindingService("XXXXXX-XXXX-XXXXX-XXXXX-XXXXX");

我猜这会以与查找 API 类似的方式生成请求 - C#.NET 代码示例,其中 appID 是 X 的系列。我猜你忘了request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");改成 request.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findCompletedItems");. 简单的解决方案是将请求的类型传递给它。例如。

public static CustomFindingService FindingService(string requestType){ // edit
CustomFindingService findingService;
log.InfoFormat("Connect to Ebay: START");

findingService = new CustomFindingService("XXXXXX-XXXX-XXXXX-XXXXX-XXXXX", requestType); // EDIT
findingService.UseDefaultCredentials = true;

log.InfoFormat("Connect to Ebay: SUCCESS");
return findingService;
   }

var fcir = new FindCompletedItemsRequest {keywords = "5mp", categoryId =new string[] {"31388"}}; // 31388 is digital cameras
var l = FindingService(fcir.GetType().Name).findCompletedItems(fcir); // Edit
// Or since you know the Name already just skip the whole get type thing and pass it in directly.

还,

log.InfoFormat("Connect to Ebay: SUCCESS");
return findingService;

我敢肯定这是不正确的。您在生成请求时没有连接。而是在var l = FindingService().findCompletedItems(fcir);.

于 2012-09-16T01:57:36.893 回答