• Resolved kevindree

    (@kevindree)


    In postman , I tried to call /wp-json/wc/v3/products end point to create a variable product, but I got bellow response.

    {
        "code": "rest_invalid_param",
        "message": "Invalid parameter(s): type",
        "data": {
            "status": 400,
            "params": {
                "type": "type is not simple."
            },
            "details": {
                "type": {
                    "code": "rest_not_in_enum",
                    "message": "type is not simple.",
                    "data": null
                }
            }
        }
    }

    In the request, I send the exact the same body like the woocommerce REST API document without any change. https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#product-properties

    {
      "name": "Ship Your Idea",
      "type": "variable",
      "description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
      "short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
      "categories": [
        {
          "id": 9
        },
        {
          "id": 14
        }
      ],
      "images": [
        {
          "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg"
        },
        {
          "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg"
        },
        {
          "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg"
        },
        {
          "src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg"
        }
      ],
      "attributes": [
        {
          "id": 6,
          "position": 0,
          "visible": false,
          "variation": true,
          "options": [
            "Black",
            "Green"
          ]
        },
        {
          "name": "Size",
          "position": 0,
          "visible": true,
          "variation": true,
          "options": [
            "S",
            "M"
          ]
        }
      ],
      "default_attributes": [
        {
          "id": 6,
          "option": "Black"
        },
        {
          "name": "Size",
          "option": "S"
        }
      ]
    }

    But If I change the type from “variable” to “simple”, it will be created normally.

    don’t know what is this issue, please help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kevindree

    (@kevindree)

    My mistake, there is a plugin restricted creation of variable products

    Hi @kevindree

    It seems that you’ve found the cause, which is a plugin installed having some restrictions or rules in place that affected the type of products that could be created using the WooCommerce API.

    I’m going to mark this thread as resolved, but please don’t hesitate to start a new topic if you have any more questions down the line.

    Have a fantastic day!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘REST API create variable product got 400 error: Invalid parameter(s): type’ is closed to new replies.