Amazon API ItemSearch 返回 (400) 错误请求

发布于 2024-09-04 01:33:59 字数 2084 浏览 3 评论 0原文

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

这是代码:

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();

出了什么问题?

I'm using a simple example from Amazon documentation for ItemSearch and I get a strange error:
"The remote server returned an unexpected response: (400) Bad Request."

This is the code:

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();

What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-09-11 01:33:59

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

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

You receive this message because your request is not signed. Starting from August 2009 all requests must be signed.

Here you can see at the example about how to sign amazon requests:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2480&categoryID=14

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文