Closed aniruddhaad closed 3 years ago
Be carefull closing tag:
document invalid error
<?xml version="1.0"?>
if you put a space between " and ? symbols, it should work.
<?xml version="1.0" ?>
Sorry for late reply. The issue was solved by providing proper input to the call. I figured this out after debugging and checking class parameters and amazon documentation.
BTW, there is another bug in the createFeed function. When you pass the json encoded string as input to the function call - PHP Warning: ksort() expects parameter 1 to be array, string given in /var/www/vhosts/w2bshop.com/amz.w2bshop.com/spapi-php/src/Client.php on line 69
Hi @aniruddhaad i'm still getting same error, Can u please provide correct Product XML Feed ? HEre is the error (i'm using production mode not Sandbox)
upload completely sent off: 200 out of 200 bytes HTTP/1.1 400 Bad Request Date: Fri, 08 Oct 2021 11:56:28 GMT Content-Type: application/json Content-Length: 117 Connection: keep-alive x-amzn-RequestId: 27306ffa-0620-4340-8348-70b1e4ead8ef x-amzn-RateLimit-Limit: 0.0083 x-amz-apigw-id: G4y87EeOoAMFd8Q= X-Amzn-Trace-Id: Root=1-616031ec-04ed798a50c4d1ee67bc5462
Connection #1 to host sellingpartnerapi-na.amazon.com left intact ETHON: performed EASY effective_url=https://sellingpartnerapi-na.amazon.com/feeds/2020-09-04/feeds response_code=400 return_code=ok total_time=0.292145 HTTP response body ~BEGIN~ { "errors": [ { "code": "InvalidInput", "message": "Invalid Input", "details": "" } ] } ~END~
AmzSpApi::ApiError: Error message: the server returns an error HTTP status code: 400 Response headers: {"Date"=>"Fri, 08 Oct 2021 11:56:28 GMT", "Content-Type"=>"application/json", "Content-Length"=>"117", "Connection"=>"keep-alive", "x-amzn-RequestId"=>"27306ffa-0620-4340-8348-70b1e4ead8ef", "x-amzn-RateLimit-Limit"=>"0.0083", "x-amz-apigw-id"=>"G4y87EeOoAMFd8Q=", "X-Amzn-Trace-Id"=>"Root=1-616031ec-04ed798a50c4d1ee67bc5462"} Response body: { "errors": [ { "code": "InvalidInput", "message": "Invalid Input", "details": "" } ] }
any thoughts?
-- Muhammad Ateq
Hi Muhammad,
Seems like you are using VB. I can not provide code for VB but here is complete code in php -
$tokenStorage = new DoubleBreak\Spapi\SimpleTokenStorage('./aws-tokens');
$signer = new DoubleBreak\Spapi\Signer();
$credentials = new DoubleBreak\Spapi\Credentials($tokenStorage, $signer, $config);
$cred = $credentials->getCredentials();
$contentType = 'text/xml; charset=UTF-8';
// create feed document
$feedClient = new \DoubleBreak\Spapi\Api\Feeds($cred, $config);
$response = $feedClient->createFeedDocument(["contentType" => $contentType]);
$feedDocumentId=$response['payload']['feedDocumentId'];
$payload = $response['payload'];
$feedContentFilePath = './sample.xml';
$result = (new \DoubleBreak\Spapi\Helper\Feeder())->uploadFeedDocument($payload,$contentType,$feedContentFilePath);
try{
$result=$feedClient->createFeed(json_encode(['feedType'=>'POST_PRODUCT_DATA','marketplaceIds'=>['A2EUQ1WTGCTBG2'],'inputFeedDocumentId'=>$feedDocumentId]));//
var_dump($result);
}
catch (\GuzzleHttp\Exception\ClientException $e) {
echo "\nLINE NO: ".__LINE__."\n";
$httpCode = $e->getResponse()->getStatusCode();
$errorBody = $e->getResponse()->getBody();
echo "Amazon SP API responded with HTTP {$httpCode}\n {$errorBody}";
exit;
}
and here is sample.xml- sample.txt You can rename the extension from txt to xml
Enjoy
Hi, Since production account is not working. I tried using sandbox and got following response while uploading products feed- {"errors":[{"code":"400","message":"Invalid input","details":"Invalid input"}]}
Here is complete output -
About to connect() to sandbox.sellingpartnerapi-na.amazon.com port 443 (#0)
Trying 52.2.145.149...
Connected to sandbox.sellingpartnerapi-na.amazon.com (52.2.145.149) port 443 (#0)
Initializing NSS with certpath: sql:/etc/pki/nssdb
skipping SSL peer certificate verification
SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
Server certificate:
subject: CN=sandbox.sellingpartnerapi-na.amazon.com
start date: May 22 00:00:00 2021 GMT
expire date: Jun 20 23:59:59 2022 GMT
common name: sandbox.sellingpartnerapi-na.amazon.com
issuer: CN=Amazon,OU=Server CA 1B,O=Amazon,C=US
upload completely sent off: 42 out of 42 bytes < HTTP/1.1 400 Bad Request < Date: Mon, 07 Jun 2021 08:32:59 GMT < Content-Type: application/json < Content-Length: 79 < Connection: keep-alive < x-amzn-RequestId: 31d913d4-9876-436c-9f7f-09d399271ae9 < x-amz-apigw-id: Ai71OFGnIAMFcoA= < X-Amzn-Trace-Id: Root=1-60bdd9ba-47306d8a43a72d5c2b5acadd;Sampled=0 <
Connection #0 to host sandbox.sellingpartnerapi-na.amazon.com left intact PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://sandbox.sellingpartnerapi-na.amazon.com/feeds/2020-09-04/documents
resulted in a400 Bad Request
response: {"errors":[{"code":"400","message":"Invalid input","details":"Invalid input"}]} in spapi-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace:0 spapi-php/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create()
1 spapi-php/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp{closure}()
2 spapi-php/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler()
3 spapi-php/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
4 / in spapi-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
Please find attached product XML feed. split-amazon-products-1.txt