OK then you need to sent a POST request with a correctly formatted JSON in the body to create new product, and a PUT if you want to update an existing product. Try using Postman to help you with this.
Understand that once you’ve done this, the data will reside in your wordpress site. but new products and updated products you can use the methods explained above.
The rest endpoints are well explained in the documentation that I provided a link for above.
Example of a PUT product update JSON:
{
“name”: “First Test Product Title Change by REST”,
“slug”: “first-product”,
“description”: “<h2>This product was created in WordPress using the standard WordPress / WooCommerce Environment</h2>\n<p>It’s a simple product, with no variations.</p>\n”,
“short_description”:”First Test Product “,
“regular_price”: “199.50”
}
/* —————————- */
the URL would be something like this with the method set to PUT(product id is 18 in this case:
https://example.com/wp-json/wc/v2/products/18?consumer_key=insert_consumer_key&consumer_secret=insert_consumer_secret
/* —————————- */
Example of a POST new product JSON
{
“name”: “API-Generated Product”,
“slug”: “api-generated”,
“permalink”: “https://example.com/product/api-generated/”,
“type”: “simple”,
“status”: “publish”,
“featured”: false,
“catalog_visibility”: “visible”,
“description”: “<h2>Created using WC REST API</h2>\n<p>Create the JSON data without an id value.</p><p>Use POST (not put). Remember to include consumer key & secret.</p>\n”,
“short_description”: “<p>REST API POST call</p>\n”,
“sku”: “wprestapi_1”,
“price”: “100.00”,
“regular_price”: “100.00”,
“sale_price”: “”,
“date_on_sale_from”: null,
“date_on_sale_from_gmt”: null,
“date_on_sale_to”: null,
“date_on_sale_to_gmt”: null,
“price_html”: “<span class=\”woocommerce-Price-amount amount\”><span class=\”woocommerce-Price-currencySymbol\”>$</span>0.02</span>”,
“on_sale”: false,
“purchasable”: true,
“total_sales”: 0,
“virtual”: false,
“downloadable”: false,
“downloads”: [],
“download_limit”: -1,
“download_expiry”: -1,
“external_url”: “”,
“button_text”: “”,
“tax_status”: “taxable”,
“tax_class”: “”,
“manage_stock”: false,
“stock_quantity”: null,
“in_stock”: true,
“backorders”: “no”,
“backorders_allowed”: false,
“backordered”: false,
“sold_individually”: false,
“weight”: “”,
“dimensions”: {
“length”: “”,
“width”: “”,
“height”: “”
},
“shipping_required”: true,
“shipping_taxable”: true,
“shipping_class”: “”,
“shipping_class_id”: 0,
“reviews_allowed”: false,
“average_rating”: “0.00”,
“rating_count”: 0,
“related_ids”: [],
“upsell_ids”: [],
“cross_sell_ids”: [],
“parent_id”: 0,
“purchase_note”: “”,
“categories”: [
{
“id”: 17,
“name”: “Main Category”,
“slug”: “main-category”
},
{
“id”: 18,
“name”: “Sub Category”,
“slug”: “sub-category”
}
],
“tags”: [],
“images”: [ ],
“attributes”: [],
“default_attributes”: [],
“variations”: [],
“grouped_products”: [],
“menu_order”: 0,
“meta_data”: [
],
“_links”: {
“self”: [],
“collection”: []
}
}
/* —————————- */
the URL would be something like this with the method set to POST:
https://example.com/wp-json/wc/v2/products/?consumer_key=insert_consumer_key&consumer_secret=insert_consumer_secret