Code Monkey home page Code Monkey logo

Comments (8)

jlevers avatar jlevers commented on July 20, 2024

Sorry my example isn't working for you! I tried to do some testing in order to figure out what's wrong with the example, but right now Amazon is giving me a 400 InvalidInput error anytime I try to call createFeed. I'm getting the error even when I use code from a project that doesn't depend on this library at all, and which was certainly working a month or so ago.

I've mentioned this in a couple issues in the main SP API repository (amzn/selling-partner-api-models#1559, amzn/selling-partner-api-models#1463), and hopefully I'll get a response soon. When I'm able to upload feeds again, I'll circle back to this issue.

from selling-partner-api.

jlevers avatar jlevers commented on July 20, 2024

@lancelim8122 -- I've updated the document upload example in the README. Please give it a try and let me know if it works for you.

from selling-partner-api.

lancelim8122 avatar lancelim8122 commented on July 20, 2024

from selling-partner-api.

JosueExsim avatar JosueExsim commented on July 20, 2024

By consuming the createFeedDocument method I am getting the response id for the POST_PRODUCT_DATA type. But I can't make functions for the createFeed () method I want to create a new product, do you have an example of how to do this please?

Thanks.

from selling-partner-api.

lancelim8122 avatar lancelim8122 commented on July 20, 2024

from selling-partner-api.

lancelim8122 avatar lancelim8122 commented on July 20, 2024

from selling-partner-api.

JosueExsim avatar JosueExsim commented on July 20, 2024

I do send a feed to amazon but it's POST_ORDER_FULFILLMENT_DATA. Below is my example:

'Atzr|IwEBIKe96x5EL71kCjCA0XC3z7lGEfwxzGpUQ3G0rB2AFhDsMj5m9cSEd0U8s4NmQ7lswOvqnf-4LQup_4hSn3WWxV-Kx8_JoOBQIewpxdhtF1hlu1DsyGrCBTJwQcUIP7-Zvbfs7cjwPt5w1ySuNxJQFca14-TjZdowjKK9hljll1znxMSGCG1gnd7Rty4_A3Wks-ixSbcStFkLWXMDHcaETF3mf2xzum1rslng1CmnFdRxUpBJ6_HFVpH-GN-0a7kTW3ibB8mm35Vf6MivCMQgO2BxkXs8xOcovMgtkGSLKGWdoVHmdnoolKmw7kv6u69ppcg', // Aztr|... 'client_id' => 'amzn1.application-oa2-client.e7a3966600104f54987f3b3e62dd292f', // App ID from Seller Central, amzn1.sellerapps.app.cfbfac4a-...... 'client_secret' => '4f0cebe97bae21e68b2de69a0ed30fca83a691f157e27734c1a1353b83128616', // The corresponding Client Secret 'region' => \ClouSale\AmazonSellingPartnerAPI\SellingPartnerRegion::$FAR_EAST, // or NORTH_AMERICA / FAR_EAST 'access_key' => 'AKIAV7G4QUIH6YAQSBAC', // Access Key of AWS IAM User, for example AKIAABCDJKEHFJDS 'secret_key' => 'w4KM9j3Q0VAuUcZBp1BHbfaH6oLfD2q255Yw0TeC', // Secret Key of AWS IAM User 'endpoint' => \ClouSale\AmazonSellingPartnerAPI\SellingPartnerEndpoint::$FAR_EAST, // or NORTH_AMERICA / FAR_EAST 'role_arn' => 'arn:aws:iam::410631840271:role/SellingPartnerAPI_Role', // AWS IAM Role ARN for example: arn:aws:iam::123456789:role/Your-Role-Name ]; $accessToken = \ClouSale\AmazonSellingPartnerAPI\SellingPartnerOAuth::getAccessTokenFromRefreshToken( $options['refresh_token'], $options['client_id'], $options['client_secret'] ); $assumedRole = \ClouSale\AmazonSellingPartnerAPI\AssumeRole::assume( $options['region'], $options['access_key'], $options['secret_key'], $options['role_arn'] ); $config = \ClouSale\AmazonSellingPartnerAPI\Configuration::getDefaultConfiguration(); $config->setHost($options['endpoint']); $config->setAccessToken($accessToken); $config->setAccessKey($assumedRole->getAccessKeyId()); $config->setSecretKey($assumedRole->getSecretAccessKey()); $config->setRegion($options['region']); $config->setSecurityToken($assumedRole->getSessionToken()); //print $options['region'];die; $note = ' 1.01 gjhhjh OrderFulfillment 1 asd12 asddd122 asfjkgnds ggg hh '; $xml = new SimpleXMLElement($note); $feedApi = new \ClouSale\AmazonSellingPartnerAPI\Api\FeedsApi($config); $contentType = 'text/xml; charset=UTF-8'; // please pay attention here, the content_type will be used many time $feedDocument = $feedApi->createFeedDocument(new \ClouSale\AmazonSellingPartnerAPI\Models\Feeds\CreateFeedDocumentSpecification([ 'content_type' => $contentType, ])); $feedDocumentId = $feedDocument->getPayload()->getFeedDocumentId(); $url = $feedDocument->getPayload()->getUrl(); $key = $feedDocument->getPayload()->getEncryptionDetails()->getKey(); $key = base64_decode($key, true); $initializationVector = base64_decode($feedDocument->getPayload()->getEncryptionDetails()->getInitializationVector(), true); $encryptedFeedData = openssl_encrypt(utf8_encode(array2xml([// array2xml is my private function, you can write your own function 'data' => 'test', ], $xml)), 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $initializationVector); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 90, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $encryptedFeedData, CURLOPT_HTTPHEADER => [ 'Accept: application/xml', 'Content-Type: ' . $contentType, ], )); $response = curl_exec($curl); $error = curl_error($curl); $httpcode = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($httpcode >= 200 && $httpcode <= 299) { // success // success $createFeedParams = [ "feedType" => "POST_ORDER_FULFILLMENT_DATA", "marketplaceIds" => ["A19VAU5U5O7RUS"], "inputFeedDocumentId" => $feedDocumentId, "feedOptions" => [ "AmazonOrderID" => '250-0074400-0209446', "FulfillmentDate" => '2021-07-07T09:47:06.000Z', "FulfillmentData" => [ 'CarrierName' => 'FedEx', 'ShippingMethod' => 'FedEx First Class', 'ShipperTrackingNumber' => '781113347XXX', ], 'Item' => [ 'AmazonOrderItemCode' => '07065034910334', 'Quantity' => '1', ], ] ]; $r = $feedApi->createFeed(json_encode($createFeedParams)); $apiInstance = new \ClouSale\AmazonSellingPartnerAPI\Api\FeedsApi($config); try { print "
"; $feed_id = $r->getPayload()->getFeedId(); print "feed document"; print_r($feedDocument->getPayload()); print_r($r->getPayload()); print_r($createFeedParams); $result = $apiInstance->getFeed($feed_id); print_r($result); print "
"; } catch (Exception $e) { echo 'Exception when calling FeedsApi->getFeeds: ', $e->getMessage(), PHP_EOL; } } else { // error } function array2xml(array $data, SimpleXMLElement $xml) { foreach ($data as $k => $v) { is_array($v) ? array2xml($v, $xml->addChild($k)) : $xml->addChild($k, $v); } return $xml; } On Thu, Jul 8, 2021 at 1:54 AM JosueExsim ***@***.***> wrote: By consuming the createFeedDocument method I am getting the response id for the POST_PRODUCT_DATA type. But I can't make functions for the createFeed () method I want to create a new product, do you have an example of how to do this please? Thanks. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <[#50 (comment)](https://github.com//issues/50#issuecomment-875808499)>, or unsubscribe .

I appreciate your response.
I did it with IAM user and I get the following result.
If my API is still in draft but I'm using the production endpoint, should I see my new product in the seller's store?

feed documentClouSale\AmazonSellingPartnerAPI\Models\Feeds\CreateFeedDocumentResult Object
(
[container:protected] => Array
(
[feed_document_id] => amzn1.tortuga.3.e028fd85-807b-4631-b2a8-f2913b7c9ac5.T1H9NEZF93HCLB
[url] => https://tortuga-prod-na.s3-external-1.amazonaws.com/%2FNinetyDays/amzn1.tortuga.3.e028fd85-807b-4631-b2a8-f2913b7c9ac5.T1H9NEZF93HCLB?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210708T160940Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=300&X-Amz-Credential=AKIA5U6MO6RAITE6VEGB%2F20210708%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=24c2b6c7e4628fb13fdcde442f0c58b7cafb40a8f23eb438c54c26f2778a7cf7
[encryption_details] => ClouSale\AmazonSellingPartnerAPI\Models\Feeds\FeedDocumentEncryptionDetails Object
(
[container:protected] => Array
(
[standard] => AES
[initialization_vector] => KUQm8S7Fri1+egOQaFqPHQ==
[key] => jv0+fW5Cwnv8Eb/Y96cXxzg6YQ1A6k4rs5hN3vZC4s0=
)

            )

    )

)
ClouSale\AmazonSellingPartnerAPI\Models\Feeds\CreateFeedResult Object
(
[container:protected] => Array
(
[feed_id] => 50004018816
)

)
Array
(
[feedType] => POST_ORDER_FULFILLMENT_DATA
[marketplaceIds] => Array
(
[0] => A1AM78C64UM0Y8
)

[inputFeedDocumentId] => amzn1.tortuga.3.e028fd85-807b-4631-b2a8-f2913b7c9ac5.T1H9NEZF93HCLB
[feedOptions] => Array
    (
        [AmazonOrderID] => 250-0074400-0209446
        [FulfillmentDate] => 2021-07-07T09:47:06.000Z
        [FulfillmentData] => Array
            (
                [CarrierName] => FedEx
                [ShippingMethod] => FedEx First Class
                [ShipperTrackingNumber] => 781113347XXX
            )

        [Item] => Array
            (
                [AmazonOrderItemCode] => 07065034910334
                [Quantity] => 1
            )

    )

)
ClouSale\AmazonSellingPartnerAPI\Models\Feeds\GetFeedResponse Object
(
[container:protected] => Array
(
[payload] => ClouSale\AmazonSellingPartnerAPI\Models\Feeds\Feed Object
(
[container:protected] => Array
(
[feed_id] => 50004018816
[feed_type] => POST_ORDER_FULFILLMENT_DATA
[marketplace_ids] => Array
(
[0] => A1AM78C64UM0Y8
)

                        [created_time] => DateTime Object
                            (
                                [date] => 2021-07-08 16:09:41.000000
                                [timezone_type] => 1
                                [timezone] => +00:00
                            )

                        [processing_status] => IN_QUEUE
                        [processing_start_time] => 
                        [processing_end_time] => 
                        [result_feed_document_id] => 
                    )

            )

        [errors] => 
    )

)

from selling-partner-api.

jlevers avatar jlevers commented on July 20, 2024

@lancelim8122 @JosueExsim if you're using the ClouSale library, please ask for support there.

from selling-partner-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.