Hi All,
I’m a bit of a beginner in the grand scheme of things, and I’m using an unsupported language to do my integration, but I feel like something obvious is missing and after re-reading all the API documentation, I still have no idea what is going wrong.
Working off the API documentation, but with my own Item, I generate a JSON request such as:
curl https://connect.squareupsandbox.com/v2/catalog/object \
-X POST \
-H 'Square-Version: 2022-06-16' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"idempotency_key": "24bf222c-21a8-4bd2-9097-b7e7ec3d2f36",
"object": {
"type": "ITEM",
"id": "#1298498081",
"is_deleted": false,
"present_at_all_locations": true,
"item_data": {
"description": "Grey Cat",
"name": "Grey Cat",
"available_online": true,
"available_for_pickup": true,
"category_id": "P4KZKJNAOWNT7JIU6GRTWNAL",
"image_ids": [
"HSVH4KFM2RWCAPUFOB2EWJ3T"
],
"tax_ids": [
"AUSSALESTAXMLQZ38K6X6A1N"
],
"product_type": "REGULAR",
"variations": [
{
"type": "ITEM_VARIATION",
"id": "#1298main",
"is_deleted": false,
"item_variation_data": {
"image_ids": [
"HSVH4KFM2RWCAPUFOB2EWJ3T"
],
"inventory_alert_type": "NONE",
"item_id": "#1298498081",
"name": "Grey Cat",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1989,
"currency": "AUD"
},
"sellable": true,
"stockable": true,
"stockable_conversion": {
"nonstockable_quantity": "0",
"stockable_quantity": "1",
"stockable_item_variation_id": "#1298main"
},
"inventory_alert_threshold": 0
}
}
]
},
"version": 0
}
}'
and I get the following error:
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "BAD_REQUEST",
"detail": "Bad request."
}
]
}
BAD_REQUEST doesn’t really give me any guidance as to what the problem is, but I got this far by drilling through the various errors the API threw back at me. Without “item_data” I get a “Missing Item Data” error. Without a “variations”, I get a “Variation missing” error. If I continue down this path, I get various errors about the lack of category, lack of stockable_conversion, lack of inventory_alert_type, etc.
I tried going off the example given at https://developer.squareup.com/reference/square/catalog/upsert-catalog-object:
curl https://connect.squareup.com/v2/catalog/object \
-X POST \
-H 'Square-Version: 2022-06-16' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"idempotency_key": "af3d1afc-7212-4300-b463-0bfc5314a5ae",
"object": {
"id": "#Cocoa",
"type": "ITEM",
"item_data": {
"abbreviation": "Ch",
"description": "Hot Chocolate",
"name": "Cocoa",
"variations": [
{
"id": "#Small",
"type": "ITEM_VARIATION",
"item_variation_data": {
"item_id": "#Cocoa",
"name": "Small",
"pricing_type": "VARIABLE_PRICING"
}
},
{
"id": "#Large",
"type": "ITEM_VARIATION",
"item_variation_data": {
"item_id": "#Cocoa",
"name": "Large",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 400,
"currency": "USD"
}
}
}
]
}
}
}'
But it appears to be missing a heap of the fields I’ve been told are required by the API.
Sorry if this seems rambling, but I’ve spent about 6 hours trying to troubleshoot a JSON object and the request, and I have no more information on what’s missing. I’ve tried looking for similar queries, but there has been nothing obviously analogous to my situation.