【问题标题】:Amazon Product advertising c# api亚马逊产品广告 c# api
【发布时间】:2014-03-30 23:19:52
【问题描述】:

大家好,我无法从 amazon web api 获取产品。

我使用了来自互联网的这段代码,添加了所有必要的参考资料。我尝试添加视图并选择 itemsearchresponce 作为模型类,但它不显示产品,我收到以下错误:

无法生成临时类(结果=1)。 错误 CS0029:无法将类型“AmazonProduct.com.amazon.webservices.ImageSet”隐式转换为 'AmazonProduct.com.amazon.webservices.ImageSet[]'

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using AmazonProduct.com.amazon.webservices;
namespace Forest.Controllers
{
    public class AmazonController : Controller
    {
        private AmazonProduct.com.amazon.webservices.AWSECommerceService _Products;

        public AmazonController()
        {
            _Products = new AmazonProduct.com.amazon.webservices.AWSECommerceService();
        }

        [HttpGet]
        public ActionResult  listProducts()
        {
            var searchIndex = "Shoes";
            var keywords = "jordan";
            // Create an ItemSearch wrapper
            ItemSearch search = new ItemSearch();
            search.AssociateTag = "[Your Associate ID]";
            search.AWSAccessKeyId = "MyKey";
            // search.Version= "2011-08-01";

            // Create a request object
            ItemSearchRequest request = new ItemSearchRequest();

            // Fill the request object with request parameters
            request.ResponseGroup = new string[] { "ItemAttributes" };

            // Set SearchIndex and Keywords
            request.SearchIndex = searchIndex;
            request.Keywords = keywords;

            // Set the request on the search wrapper
            search.Request = new ItemSearchRequest[] { request };

            ItemSearchResponse response = _Products.ItemSearch(search);

            return View(response);
        }
    }
}

【问题讨论】:

  • 由于您只是将结果与视图一起传回,因此错误很可能发生在您使用 ImageSet 的视图中。该错误似乎表明您的结果实际上是一个 ImageSet[](ImageSet 对象数组),而在您的代码中的某处 - 而不是您发布的代码 - 您试图将该结果视为单个 ImageSet。找到那个地方,你就会发现问题。或发布相关视图代码以获得更多帮助。

标签: c# asp.net-mvc-3 api amazon


【解决方案1】:

转到生成的代理并将ImageSet[][]替换为ImageSet[]
如果您还没有,也可以看看Amazon Product Advertising API C#

【讨论】:

    猜你喜欢
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-29
    • 1970-01-01
    相关资源
    最近更新 更多