2016-03-29 89 views
4

我試圖調用GetLowestPricedOffersForSKU時有輕微的問題,我得到的迴應:GetLowestPricedOffersForSKU失敗處理參數

Failed processing arguments of org.jboss.resteasy.spi.metadata

我可以調用其他函數在產品阿比他們的工作很好,只是得到上面的錯誤這個功能。

我已經找到了答案的網絡,但找不到與此有關的任何內容,有沒有人有任何想法,爲什麼我得到這個?

順便說一下,它在MWS Scratchpad中一切正常!

+0

使用哪個客戶端庫? –

回答

0

此代碼適用於我。希望它能幫助別人。

<?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"); 
     } 
    } 
    ?> 
+0

嗨保羅, 感謝您的信息,我會給它一個去看看會發生什麼。 – Potman100

3

發佈以防其他人遇到此問題,並且與我一樣困惑。除了這個特殊的亞馬遜MWS請求外,幾乎所有的亞馬遜MWS請求都有一個基本的區別。所有其他請求在技術上接受參數作爲查詢參數而不是POST數據。暫存器甚至表明這是實際工作方式(儘管MWS Scratchpad實際上也將數據作爲後期數據字段發送)。

+1

以及這個如何表現? – YakovL

0

MWS需要將POST數據作爲表單參數傳遞,而不是作爲某些操作的查詢字符串傳遞。否則,它會爲此類操作(GetMyFeesEstimate是另一種受此影響的操作)錯誤風格400 Bad Request錯誤。

舉例來說,如果你在狂飲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', 
    ] 
]);