【问题标题】:Amazon API ItemSearch returns (400) Bad RequestAmazon API ItemSearch 返回 (400) 错误请求
【发布时间】:2010-05-30 12:25:16
【问题描述】:

我正在使用 Amazon 文档中的一个简单示例进行 ItemSearch,但我收到了一个奇怪的错误: “远程服务器返回了意外响应:(400) Bad Request。”

这是代码:

public static void Main()
        {
            //Remember to create an instance of the amazon service, including you Access ID. 

            AWSECommerceServicePortTypeClient service = new AWSECommerceServicePortTypeClient(new BasicHttpBinding(),
                                                                                              new EndpointAddress(
                                                                                                "http://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));


            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
             new BasicHttpBinding(),
             new EndpointAddress("http://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            // prepare an ItemSearch request  
            ItemSearchRequest request = new ItemSearchRequest();
            request.SearchIndex = "Books";
            request.Title = "Harry+Potter";
            request.ResponseGroup = new string[] { "Small" };
            ItemSearch itemSearch = new ItemSearch();
            itemSearch.Request = new ItemSearchRequest[] { request };
            itemSearch.AWSAccessKeyId = accessKeyId;

            // issue the ItemSearch request
            try
            {
                ItemSearchResponse response = client.ItemSearch(itemSearch);
                // write out the results  

                foreach (var item in response.Items[0].Item)
                {
                    Console.WriteLine(item.ItemAttributes.Title);
                }
            }
            catch(Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Press any key to quit...");
                Clipboard.SetText(e.Message);
            }
            Console.ReadKey();

怎么了?

【问题讨论】:

    标签: amazon-web-services amazon-product-api


    【解决方案1】:

    您收到此消息是因为您的请求未签名。从 2009 年 8 月开始,所有请求都必须签名。

    您可以在此处查看有关如何签署亚马逊请求的示例: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2480&categoryID=14

    【讨论】:

    • 链接已损坏。答案坏了。可以更新吗?这是否仍然相关。抱歉必须-1
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多