0

我正在使用 C# Amazon SP-API 库,我已经使用 swagger codegen 转换了 C# 包装器类,并且在 Pricing 以及 Reports API 中的一些功能上都可以正常工作。

但是当我尝试调用 getReportDocument 时,它给出了 AWS 签名不匹配的错误。

https://github.com/amzn/ sell-partner-api-docs/blob/main/references/reports-api/reports_2020-09-04.md#getreportdocument

4

1 回答 1

1

如果您可以确认问题仅在通过 id (如 GetOrder、GetReport)调用单个项目时出现,并且您正在使用亚马逊提供的 Amazon.SellingPartnerAPIAA.csproj 进行签名,则很可能AWSSigV4Signer.CreateCanonicalRequestMethod 使用段占位符而不是 id 对 url进行签名本身。

例如“/reports/2021-06-30/documents/{reportDocumentId}”而不是“/reports/2021-06-30/documents/0356cf79-b8b0-4226-b4b9-0ee058ea5760”一种可能的解决方案是通过打电话之前的“手”ExtractCanonicalURIParameters

foreach(var par in restRequest.Parameters)
{
   if(restRequest.Resource.Contains($"{{{par.Name}}}"))
   {
        restRequest.Resource = restRequest.Resource.Replace($"{{{par.Name}}}", par.Value.ToString());
   }
}

//CanonicalURI
canonicalizedRequest.AppendFormat("{0}\n", AwsSignerHelper.ExtractCanonicalURIParameters(restRequest.Resource));
于 2022-02-23T11:50:05.400 回答