在我的asp.net网络应用程序中,我正在使用亚马逊插件来加载具有相应的isbn.in代码的书籍图像。我正在将该图像转换为字节数组,以便将其存储到数据库中。但问题是它有时会再次出现错误见图片
可以指出出现此错误的原因,请向我建议一些解决方案。谢谢。
答案 0 :(得分:0)
当你达到油门限制时会发生这种情况。
尝试将代码包装在try catch块
中例如
void withretry(string query)
{
ListMatchingProductsRequest request = new ListMatchingProductsRequest();
request.SellerId = amazonsetting.merchantId;
request.MarketplaceId = amazonsetting.marketplaceId;
request.QueryContextId = "Books";
request.Query = query;
try
{
ListMatchingProductsResponse response = amazonsetting.service.ListMatchingProducts(request);
if (response.IsSetListMatchingProductsResult())
{
ListMatchingProductsResult listMatchingProductsResult = response.ListMatchingProductsResult;
if (listMatchingProductsResult.IsSetProducts())
{
ProductList products = listMatchingProductsResult.Products;
List<Product> productList = products.Product;
Product product = productList[0];
if (product.IsSetIdentifiers())
{
IdentifierType identifiers = product.Identifiers;
if (identifiers.IsSetMarketplaceASIN())
{
ASINIdentifier marketplaceASIN = identifiers.MarketplaceASIN;
if (marketplaceASIN.IsSetMarketplaceId())
{
}
if (marketplaceASIN.IsSetASIN())
{
asin = marketplaceASIN.ASIN;
}
}
}
if (product.IsSetAttributeSets())
{
foreach (var attribute in product.AttributeSets.Any)
{
msg += ProductsUtil.FormatXml((System.Xml.XmlElement)attribute);
}
}
}
parsemsg();
}
}
catch (Exception ex)
{
string type = ex.Message;
if (type=="Request is throttled")
{
if (cnt<=maxretry)
{
cnt++;
withretry(query);
}
}
}
}
这将继续重试,直到达到maxretry。