【问题标题】:GetLowestPricedOffersForSKU failed processing argumentsGetLowestPricedOffersForSKU 处理参数失败
【发布时间】:2016-03-29 19:45:39
【问题描述】:

我在尝试调用 GetLowestPricedOffersForSKU 时遇到了一个小问题,我收到了回复:

org.jboss.resteasy.spi.metadata 处理参数失败

我可以调用 Product Api 中的其他函数,它们工作正常,只是在这个函数上出现上述错误。

我已经在网上寻找答案,但找不到与此相关的任何内容,有人知道我为什么会得到这个吗?

顺便说一句,在 MWS Scratchpad 中一切正常!

【问题讨论】:

  • 使用哪个客户端库?

标签: amazon-mws


【解决方案1】:

发帖以防其他人遇到这个问题并且和我一样困惑。除了这个特定的请求之外,几乎所有亚马逊 MWS 请求的工作方式都存在根本差异。所有其他请求在技术上接受参数作为查询参数而不是 POST 数据。暂存器甚至表明它实际上是这样工作的(尽管 MWS 暂存器实际上也将数据作为发布数据字段发送)。

【讨论】:

  • 这个行为如何?
【解决方案2】:

MWS 需要将 POST 数据作为表单参数而不是作为查询字符串传递给某些操作。否则,对于某些操作(例如此操作)会产生 Failed processing arguments of org.jboss.resteasy.spi.metadata 样式 400 Bad Request 错误(GetMyFeesEstimate 是另一个受此影响的操作)。

例如,如果您在 Guzzle 6 中执行以下 POST 请求,那么您可能会收到错误:

$response = $client->request('POST', 'https://mws.amazonservices.com/Products/2011-10-01/?AWSAccessKeyId=YOURAWSACCESSKEY&Action=GetLowestPricedOffersForASIN&SellerId=YOURSELLERID&MWSAuthToken=amzn.mws.fghsffg-4t44e-hfgh-dfgd-zgsdbfe5erg&SignatureVersion=2&Timestamp=2017-07-09T15%3A45%3A18%2B00%3A00&Version=2011-10-01&Signature=bCasdxXmYDCasdaXBhsdgse4pQ6hEbevML%2FJvzdgdsfdy2o%3D&SignatureMethod=HmacSHA256&MarketplaceId=ATVPDKIKX0DER&ASIN=B007EZK19E');

要解决此问题,您可以将其作为表单数据提交,如 Guzzle 6 示例中所示:

$response = $client->request('POST', 'https://mws.amazonservices.com/Products/2011-10-01', [
    'form_params' => [
        'AWSAccessKeyId' => 'YOURAWSACCESSKEY',
        'Action' => 'GetLowestPricedOffersForASIN',
        'SellerId' => 'YOURSELLERID',
        'MWSAuthToken' => 'amzn.mws.fghsffg-4t44e-hfgh-dfgd-zgsdbfe5erg',
        'SignatureVersion' => 2,
        'Timestamp' => '2017-07-09T15%3A45%3A18%2B00%3A00',
        'Version' => '2011-10-01',
        'Signature' => 'bCasdxXmYDCasdaXBhsdgse4pQ6hEbevML%2FJvzdgdsfdy2o%3D',
        'SignatureMethod' => 'HmacSHA256',
        'MarketplaceId' => 'ATVPDKIKX0DER',
        'ASIN' => 'B007EZK19E',
    ]
]);

【讨论】:

  • 如果我从 URL 中删除参数(并且只将它们放在 Post 字段中)亚马逊会抱怨缺少参数。如果我将它们留在 URL 中并将它们包含在 Post Fields 中,org.jboss.resteasy.spi.metadata 错误仍然存​​在。有什么想法吗?
  • 谢谢,这救了我。想一想像亚马逊这样大的公司不能按照他自己的文档进行操作真是太疯狂了!
【解决方案3】:

这段代码对我有用。希望它会对某人有所帮助。

<?php

    require_once('.config.inc.php');

    // More endpoints are listed in the MWS Developer Guide
    // North America:
    $serviceUrl = "https://mws.amazonservices.com/Products/2011-10-01";
    // Europe
    //$serviceUrl = "https://mws-eu.amazonservices.com/Products/2011-10-01";
    // Japan
    //$serviceUrl = "https://mws.amazonservices.jp/Products/2011-10-01";
    // China
    //$serviceUrl = "https://mws.amazonservices.com.cn/Products/2011-10-01";


     $config = array (
       'ServiceURL' => $serviceUrl,
       'ProxyHost' => null,
       'ProxyPort' => -1,
       'ProxyUsername' => null,
       'ProxyPassword' => null,
       'MaxErrorRetry' => 3,
     );

     $service = new MarketplaceWebServiceProducts_Client(
            AWS_ACCESS_KEY_ID,
            AWS_SECRET_ACCESS_KEY,
            APPLICATION_NAME,
            APPLICATION_VERSION,
            $config);


     // @TODO: set request. Action can be passed as MarketplaceWebServiceProducts_Model_GetLowestPricedOffersForSKU
     $request = new MarketplaceWebServiceProducts_Model_GetLowestPricedOffersForSKURequest();
     $request->setSellerId(MERCHANT_ID);
     $request->setMWSAuthToken(MWSAUTH_TOKEN);
     $request->setMarketplaceId(MARKETPLACE_ID);
     $request->setSellerSKU($sellerSKU);
     $request->setItemCondition($ItemCondition);
     // object or array of parameters
     invokeGetLowestPricedOffersForSKU($service, $request);


      function invokeGetLowestPricedOffersForSKU(MarketplaceWebServiceProducts_Interface $service, $request)
      {
          try {
            $response = $service->GetLowestPricedOffersForSKU($request);

            echo ("Service Response\n");
            echo ("=============================================================================\n");

            $dom = new DOMDocument();
            $dom->loadXML($response->toXML());
            $dom->preserveWhiteSpace = false;
            $dom->formatOutput = true;
            echo $dom->saveXML();
            echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");

         } catch (MarketplaceWebServiceProducts_Exception $ex) {
             echo("Caught Exception: " . $ex->getMessage() . "\n");
             echo("Response Status Code: " . $ex->getStatusCode() . "\n");
             echo("Error Code: " . $ex->getErrorCode() . "\n");
             echo("Error Type: " . $ex->getErrorType() . "\n");
             echo("Request ID: " . $ex->getRequestId() . "\n");
             echo("XML: " . $ex->getXML() . "\n");
             echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
         }
     }
    ?>

【讨论】:

  • 嗨,保罗,感谢您提供的信息,我会试一试,看看会发生什么。
【解决方案4】:

正如@eComEvoFor 所说,对于这种特殊方法,亚马逊要求您在请求正文中指定参数。在使用 axios 库的 node.js 中,您可以这样做:

const paramsSorted = {}
Object.keys(params)
  .sort()
  .forEach((key) => {
    paramsSorted[key] = params[key]
  })
const data = new URLSearchParams(paramsSorted)
url = urljoin(this.marketplace.url, this.api, this.api.Version)
const response = await axios.post(url, data)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    • 2013-04-10
    • 2021-10-04
    • 2019-10-03
    • 2022-12-10
    • 2016-06-30
    • 2014-06-24
    相关资源
    最近更新 更多