Help creating a product, getting an INVALID_REQUEST_ERROR

Hi., I am new to the Square API (using Python) and am trying to create a product using upsert_catalog_object however I am getting an error and I am stuck figuring out quite what is wrong.

Here is my request body:

{
    "idempotency_key": "b0bbd1ad-e10a-4358-8cd0-b2d881d4525a",
    "object": {
        "type": "ITEM",
        "id": "#item",
        "present_at_all_locations": false,
        "present_at_location_ids": [
            "K085TXKGCT4PT"
        ],
        "is_deleted": false,
        "image_id": "CNOOAQGBUGKR7TANJP5Z2Z6M",
        "item_data": {
            "name": "Test Item",
            "description": "<p data-mce-fragment=\"1\">Test description.</p>",
            "available_online": false,
            "variations": [
                {
                    "id": "#v0",
                    "type": "ITEM_VARIATION",
                    "item_variation_data": {
                        "item_id": "#item",
                        "name": "Default Title",
                        "sku": "my-sku",
                        "ordinal": 0,
                        "pricing_type": "FIXED_PRICING",
                        "price_money": {
                            "amount": 600,
                            "currency": "USD"
                        },
                        "track_inventory": true,
                        "inventory_alert_type": "LOW_QUANTITY",
                        "inventory_alert_threshold": 20,
                        "stockable": true,
                        "user_data": "weightGrams=40"
                    }
                }
            ]
        }
    }
}

And the error:

INVALID_REQUEST_ERROR (INVALID_VALUE): Object `#v0` of type ITEM_VARIATION is enabled at unit `3ES4EF5TZPZQ9`, but the referenced object with token `2YQATXDKZI6XQVCL7PZTB6GY` of type ITEM is not., FIELD: item_id

I appreciate any help. Thanks!

1 Like

:wave: The error is saying the ITEM_VARATION is enabled at a location the ITEM is not enabled at. The item is only enabled at K085TXKGCT4PT but the variation seems to be available everywhere (no explicit present_at_all_locations or present_at_location_ids ). :slightly_smiling_face:

1 Like