Amazon Selling Partner API - Upload Product Data

Viewed 20

I use the Selling Partner API for PHP from jlevers (https://github.com/jlevers/selling-partner-api)

Connection works after a lot of reading posts. I can get orders, order items and so on.

Now I want to try to upload product data to amazon.

Is it possible to upload the product in json format ? Or is it normal that we still upload the product data in xml format? I cant find a PHP example with json format.

I found this example: https://spapi.cyou/en/use-case/feeds-api-use-case-guide_2021-06-30.html#xml-feeds

My second question is, if I can get the categories from amazon with a Api call or is it still just an XSD file?

1 Answers

A way i did this in XML format in java is like this:

    StringBuilder stringBuilder = new StringBuilder(); //everything is hardcoded except sku & quantity
    stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\n");
    stringBuilder.append("<AmazonEnvelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"amzn-envelope.xsd\">").append("\n");
    stringBuilder.append("<Header>").append("\n");
    stringBuilder.append("<DocumentVersion>1.01</DocumentVersion>").append("\n");
    stringBuilder.append("<MerchantIdentifier>A24AHHJKC9JJQL</MerchantIdentifier>").append("\n");
    stringBuilder.append("</Header>").append("\n");
    stringBuilder.append("<MessageType>Inventory</MessageType>").append("\n");
    stringBuilder.append("<Message>").append("\n");
    stringBuilder.append("<MessageID>1</MessageID>").append("\n");
    stringBuilder.append("<Inventory>").append("\n");
    stringBuilder.append("<SKU>").append(sku).append("</SKU>").append("\n");                          //------>> SKU
    stringBuilder.append("<Quantity>").append(quantity).append("</Quantity>").append("\n");           //------>> Quantity
    stringBuilder.append("</Inventory>").append("\n");
    stringBuilder.append("</Message>").append("\n");
    stringBuilder.append("</AmazonEnvelope>");

Only SKU and Quantity are variables and have to be inputted by the program

Related