gpt4 book ai didi

amazon-web-services - Amazon API ItemSearch 返回 (400) 错误请求

转载 作者:行者123 更新时间:2023-12-04 06:52:24 25 4
gpt4 key购买 nike

我正在为 ItemSearch 使用 Amazon 文档中的一个简单示例,但出现了一个奇怪的错误:
“远程服务器返回了意外响应:(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();

怎么了?

最佳答案

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

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

关于amazon-web-services - Amazon API ItemSearch 返回 (400) 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2938591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com