Add new product in Magento through REST API

Add new product in Magento through REST API

September 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add new product in Magento through REST API

Solving API Data Persistence Issues in Magento

If you’re following the official Magento REST API documentation (Create a new product) and seeing successful HTTP responses but no changes in your database, there are a few common areas to troubleshoot.

Double-Check Your Product Data Structure

Before diving into the code, let’s ensure you’re sending the correct data format. The official documentation uses JSON for the request body. Make sure you’re not sending XML data by mistake, as this will cause the API to ignore your payload.

Here’s a simple example of what a valid JSON product object should look like:

{
  "sku": "test_product",
  "name": "Test Product",
  "weight": 1.0,
  "price": 9.99,
  "visibility": 4,
  "description": "This is a test product.",
  "short_description": "Short description of the product."
}

Verify Your Magento Version and API Configuration

Ensure you’re using a version of Magento that supports the REST API endpoints you’re trying to access. If your site is on an older version (pre-2.4), some features may not be available.

Additionally, check if the necessary APIs are enabled in your backend:

  1. Go to Stores -> Configuration -> Services -> Magento REST API.
  2. Ensure that both “Enable Web Services” and “Web Services User List” are correctly configured.
  3. Save the changes.

Debugging the API Response

The HTTP 200 response you’re seeing indicates a successful network request, but it doesn’t necessarily mean your data was saved correctly.

To debug further, check if there are any errors logs generated when you make the API call:

  1. Enable Magento’s logging for the specific API module: Mage_Log (you can use this guide to enable and view logs).
  2. Check if any exceptions are logged after your API call.

Ensuring Data Persistence with Magento 2

In Magento 2, the API responses might not reflect immediate database changes due to the implementation of mass action processing. By default, when creating a new resource via API (like a product), Magento doesn’t save it immediately to speed up performance during bulk operations.

To ensure your data is saved:

  1. Check if you have any ongoing cron jobs running that might be processing the data in the background.
  2. If you need immediate persistence for testing purposes, you can manually run the relevant indexer or cron job after making the API call.

Using Magento’s Official Examples

If you’re still having trouble, I recommend using the official examples provided by Magento to avoid any minor configuration issues.

You can find these samples on GitHub: Magento 2 Samples

These include various scenarios like creating a new customer or adding a product to an order, which can serve as reliable references for setting up your API calls correctly.

Conclusion

When working with Magento’s REST API, it’s crucial to double-check the data format, version compatibility, and backend configuration. Remember that Magento 2 uses delayed processing for some operations by default.

If you’re still facing issues after verifying these points, don’t hesitate to reach out on the official Magento Stack Exchange or contact our team at Laravel Company for further assistance in integrating Magento’s APIs into your projects.

Catalog Database API Admin

Our network