3

I need your help, I tried all the mentioned suggestions (https://github.com/amzn/selling-partner-api-docs/issues/2167) but am still not able to update the inventory quantity with Amazon SP API.

I am trying to update the quantity stock without Feeds.

Below body, I am sending to update the quantity with Put Request.

The package I am using is: https://github.com/jlevers/selling-partner-api

SellingPartnerApi\Model\ListingsV20210801\ListingsItemPutRequest Object
(
    [container:protected] => Array
        (
            [product_type] => FALSE_EYELASH
            [requirements] => 
            [attributes] => Array
                (
                    [fulfillment_availability] => Array
                        (
                            [fulfillment_channel_code] => AMAZON_JP
                            [quantity] => 5
                        )
                )
        )
)

When I use sandbox get a response ACCEPTED but without getting an error.

........
            [sku] => 2629-48KGT-2347 // TEST
            [status] => INVALID
            [submission_id] => 602b84b73b964e24b174a80d3a7870a3
            [issues] => Array
                (
                    [0] => SellingPartnerApi\Model\ListingsV20210801\Issue Object
                        (
                            [container:protected] => Array
                                (
                                    [code] => 4000003
                                    [message] => ������������Amazon������������������������������������������������������������������������������
                                    [severity] => ERROR
                                    [attribute_names] => 
                                )
                        )
                )
........

=======================

To patch the request I am trying the below body.

SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest Object
(
    [container:protected] => Array
        (
            [product_type] => FALSE_EYELASH
            [patches] => Array
                (
                    [op] => replace
                    [operation_type] => UPDATE    // Already try with or without this parameter
                    [path] => /attributes/fulfillment_availability
                    [value] => Array
                        (
                            [fulfillment_channel_code] => AMAZON_JP
                            [quantity] => 5
                        )
                )
        )
)

Get the below response.

Exception when calling: [400] {
  "errors": [
    {
      "code": "InvalidInput",
      "message": "Request has missing or invalid parameters and cannot be parsed.",
      "details": ""
    }
  ]
}

Is there any way to update the order status to shipped without the feeds API?

The code which I try so far is below.

$patchBody = [
    'product_type' => 'BEAUTY',
    'marketplaceIds' => ['A1VC38T7YXB528'], // Already try with or without
    'patches' => [
        [
            "op" => "replace",
            "operation_type" => "PARTIAL_UPDATE",
            "path" => "/attributes/fulfillment_availability",
            "value" => [
                [
                    "fulfillment_channel_code" => 'DEFAULT',
                    "quantity" => 2
                ]
            ]
        ]
    ]
];

$putBody = [
    'product_type' => 'BEAUTY',
    'attributes' => [
        "fulfillment_availability" => [
            "fulfillment_channel_code" => "DEFAULT",
            "quantity" => 2
        ]
    ]
];

$seller_id = 'MY-SELLER-ID';
$sku = '8001025974';
$marketplace_ids = array('A1VC38T7YXB528');

// Update inventory
$apiInstance = new SellingPartnerApi\Api\ListingsV20210801Api($config);

$body = new \SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest($patchBody);
// $issue_locale = 'en_US';

try {
    $result = $apiInstance->patchListingsItem($seller_id, $sku, $marketplace_ids, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling: ', $e->getMessage(), PHP_EOL;
}
aynber
  • 22,380
  • 8
  • 50
  • 63
Zaid Bin Khalid
  • 748
  • 8
  • 25

1 Answers1

2

I found the solution the main issue is in the body there are many different methods that are provided by Amazon feed base or listing put/patch base.

I am using selling partner api

In my question, I was using the Listing base approach.

The endpoint URL is below.

{{fe_url}}/listings/2021-08-01/items/{{seller_id}}/8001025974?marketplaceIds={{jp_market_id}}

The body should be like the below. If there is an error in product type even if you pass the current product type just use "PRODUCT" instead.

Note: But if you are using a feed document then it might be changed see here

I got success with the below body.

{
    "productType": "PRODUCT",
    "patches": [
        {
            "op": "replace",
            "operation_type": "PARTIAL_UPDATE",
            "path": "/attributes/fulfillment_availability",
            "value": [
                {
                    "fulfillment_channel_code": "DEFAULT",
                    "quantity": 0
                }
            ]
        }
    ]
}

The given code is a full example.

$config = new Configuration([
    "lwaClientId" => "YOUR-CLIENT-ID",
    "lwaClientSecret" => "YOUR-CLIENT-SECRET",
    "lwaRefreshToken" => "YOUR-TOKEN",
    "awsAccessKeyId" => "YOUR-ACCESS-KEY",
    "awsSecretAccessKey" => "YOUR-KEY",
    // If you're not working in the North American marketplace, change
    // this to another endpoint from lib/Endpoint.php
    "endpoint" => Endpoint::FE
]);


$seller_id = 'YOUR-ID'; // string | A selling partners identifier, such as a merchant account or vendor code.
$sku = 'YOUR-PRODUCT-CODE'; // string | A selling partner provided identifier for an Amazon listing.
$marketplace_ids = array('YOUR-MARKET-ID');


$patchBody = [
    'product_type' => 'PRODUCT',
    'patches' => [
        [
            "op" => "replace",
            "operation_type" => "PARTIAL_UPDATE",
            "path" => "/attributes/item_name",
            "value" => [
                [
                    "value" => "【ome】Colorラッシュ・セーブル レッドブラウン Cカール 0.07mm×9mm",
                    "marketplace_id" => "CHANGE-WITH-YOUR-MID"
                ]
            ],
        ]
    ]
];


// Update inventory
$apiInstance = new SellingPartnerApi\Api\ListingsV20210801Api($config);

$body = new \SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest($patchBody);

print_r($body);

try {
     $result = $apiInstance->patchListingsItem($seller_id, $sku, $marketplace_ids, $body);
     print_r($result);
} catch (Exception $e) {
     echo 'Exception when calling: ', $e->getMessage(), PHP_EOL;
}
Zaid Bin Khalid
  • 748
  • 8
  • 25
  • Still not working for me: "Request has missing or invalid parameters and cannot be parsed." – Heitor Jun 19 '23 at 03:18
  • 1
    What you have done so far can you share with us? did you try what I mentioned? – Zaid Bin Khalid Jun 21 '23 at 01:19
  • I just replicated what you have done, and also tried to do exactly the same example in the documentation page. $body = new \SellingPartnerApi\Model\ListingsV20210801\ListingsItemPatchRequest(); $body->patches = [ 'op' => 'replace', 'path' => '/attributes/fulfillment_availability', 'value' => [ 'fulfillment_channel_code' => 'DEFAULT', 'quantity' => 0 ] ]; $result = $api->patchListingsItem($seller_id, $sku, array('A2Q3Y263D00KWC'), $body); – Heitor Jun 22 '23 at 03:44
  • I tried many variations too, including also 'operation_type' => 'PARTIAL_UPDATE', – Heitor Jun 22 '23 at 03:46
  • It usually takes time to reflect the updated quantity in the AWS seller center. Try In Postman with proper headers I believe you missed something in the header. – Zaid Bin Khalid Jun 22 '23 at 07:46
  • @Heitor i have updated the code it might help you know :) – Zaid Bin Khalid Jun 22 '23 at 07:52
  • Zaid thank you so much, it's now working for quantity!!! For price I'm getting a new "The provided payload is invalid." error. This is the body: [product_type]=>PRODUCT[patches]=>Array([0]=>Array([op]=>replace[operation_type]=>PARTIAL_UPDATE[path]=>/attributes/purchasable_offer[value]=>Array([0]=>Array([marketplace_id]=>A2Q3Y263D00KWC[currency]=>BRL[our_price]=>Array([schedule]=>Array([value_with_tax]=>98.77)))))) – Heitor Jun 24 '23 at 01:58
  • Now you know the method just read the documentation of Amazon and change the parameter to update the price and other attributes. – Zaid Bin Khalid Jul 07 '23 at 00:54
  • I already did read the documentation...still struggling. – Heitor Jul 08 '23 at 00:48
  • Ok I found the issue: for quantity have to use 'path' => '/attributes/purchasable_offer' an it worked fine! For price I'm trying to use use 'path' => '/attributes/list_price' but still not working, it's giving an error message. – Heitor Jul 18 '23 at 23:11
  • For price have to use use 'path' => '/attributes/list_price' and [value] => ( [0] => Array ( [marketplace_id] => A2Q3123400KWC [currency] => BRL [value] => 87.65 ) ) – Heitor Jul 18 '23 at 23:49