VERSION_MISMATCH issue using C#

I am new to using this, so please bear with me. I am using BatchUpsertCatalogObjectsAsync to upsert changes to catalog objects (ITEM, ITEM_VARIATION). When I am trying to actually update an existing object, I am getting the following

Object version does not match latest database version.

I did check and the version numbers in my ODS do match the version number in Square, so I am at a loss for what is causing this and how to fix it? I am using the .net SDK. Any help would be GREATELY appreciated!

What’s your application ID and the catalog_object_id that you’re trying to update? :slightly_smiling_face:

I am not sure what you mean by application id?

The catalog_object_id is OB7B5TIHOV2Z6MW2DOU4WMSO

Looking at the API logs when you called BatchUpsertCatalogObjects the request didn’t include a version for that object which is why you got the error. You’ll need to add the current version of the object to the request to get it to succeed. :slightly_smiling_face:

How do I specify the version when making the call? I keep the version in our ODS, I just need to know where to put it in the request. Thank you :slight_smile:

If you’re storing the version of the object in your ODS you can pass the version in with the request when updating. For example you’ll see the version in this object. If you pass the existing version of the object in the update request it will resolve this error:

{
    "object": {
        "type": "ITEM",
        "id": "IPFY5CUTXOYG3PBXHQGDKBXM",
        "updated_at": "2022-09-27T16:22:03.965Z",
        "created_at": "2019-12-26T17:13:27.337Z",
        "version": 1664295723965,
        "is_deleted": false,
        "present_at_all_locations": true,
        "item_data": {
            "name": "Hex Coffee",
            "description": "Hot Bean Juice",
            "label_color": "FBD6E4",
            "visibility": "PRIVATE",
            "available_online": false,
            "available_for_pickup": false,
            "available_electronically": false,
            "category_id": "RU5WBWNYPWLERUQBCVSQQVEG",
            "ordinal": 0,
            "tax_ids": [
                "QZR25LKZ23SLVOPWFLJ4J3MS",
                "ZPTKVRGA2UDO2OZWL6ULID3H"
            ],
            "modifier_list_info": [
                {
                    "modifier_list_id": "M2JDAVYQCJEK2KAUTVJAYRTK",
                    "min_selected_modifiers": -1,
                    "max_selected_modifiers": -1,
                    "enabled": true
                },
                {
                    "modifier_list_id": "NEQACTCWKO4HVDJIF7R5GU4I",
                    "min_selected_modifiers": -1,
                    "max_selected_modifiers": -1,
                    "enabled": true
                }
            ],
            "variations": [
                {
                    "type": "ITEM_VARIATION",
                    "id": "UXTWXOHG5HBKM65MLIBUKMQF",
                    "updated_at": "2022-09-27T16:22:03.965Z",
                    "created_at": "2019-12-26T17:13:27.337Z",
                    "version": 1664295723965,
                    "is_deleted": false,
                    "present_at_all_locations": true,
                    "item_variation_data": {
                        "item_id": "IPFY5CUTXOYG3PBXHQGDKBXM",
                        "name": "Regular",
                        "sku": "12348",
                        "ordinal": 1,
                        "pricing_type": "FIXED_PRICING",
                        "price_money": {
                            "amount": 280,
                            "currency": "USD"
                        },
                        "location_overrides": [
                            {
                                "location_id": "3Z4V4WHQK64X9",
                                "track_inventory": false
                            }
                        ],
                        "sellable": true,
                        "stockable": true
                    }
                },
                {
                    "type": "ITEM_VARIATION",
                    "id": "MDTZQGRYTEAV5F5ZA3QWRSOX",
                    "updated_at": "2022-09-14T21:32:51.988Z",
                    "created_at": "2019-12-26T17:13:27.337Z",
                    "version": 1663191171988,
                    "is_deleted": false,
                    "present_at_all_locations": true,
                    "item_variation_data": {
                        "item_id": "IPFY5CUTXOYG3PBXHQGDKBXM",
                        "name": "Large",
                        "sku": "09876",
                        "ordinal": 2,
                        "pricing_type": "FIXED_PRICING",
                        "price_money": {
                            "amount": 350,
                            "currency": "USD"
                        },
                        "location_overrides": [
                            {
                                "location_id": "3Z4V4WHQK64X9",
                                "track_inventory": false
                            }
                        ],
                        "sellable": true,
                        "stockable": true
                    }
                }
            ],
            "product_type": "REGULAR",
            "skip_modifier_screen": true,
            "ecom_uri": "https://boats-freedive.square.site/product/hex-coffee/20",
            "ecom_available": true,
            "ecom_visibility": "VISIBLE",
            "pickup_fulfillment_preferences_id": "fprefs_127djg37q08dwyf33ihh4q39x",
            "delivery_fulfillment_preferences_id": "fprefs_127djg37pbjevxpdk6ue90r9x",
            "description_html": "Hot Bean Juice",
            "description_plaintext": "Hot Bean Juice"
        }
    }
}

:slightly_smiling_face:

That is exactly what I needed to know. I want to let everyone know that

CatalogObject.Builder.Version()

is where you need to put it when using the .net SDK