Hello there Square folks,
I am facing a weird problem with the Java API. Namely, if I go to the API explorer and build up my request, the resulting curl
payload:
curl https://connect.squareupsandbox.com/v2/catalog/object \
-X POST \
-H 'Square-Version: 2020-11-18' \
-H 'Authorization: Bearer MY_SANDBOX_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"idempotency_key": "77e59159-9c23-4b20-b4b4-5bfbdef7482d",
"object": {
"id": "#RANDOM_ID",
"type": "ITEM",
"item_data": {
"abbreviation": "RAM",
"description": "Will challenge his father for the throne",
"label_color": "7FAAD4",
"name": "RAMSES V",
"variations": [
{
"id": "#RANDOM_ID_VAR",
"type": "ITEM_VARIATION",
"item_variation_data": {
"item_id": "#RANDOM_ID",
"name": "RAMSES V_DEFAULT_VARIATION",
"price_money": {
"amount": 10000,
"currency": "USD"
},
"pricing_type": "FIXED_PRICING",
"sku": "RANDOM_SKU",
"upc": "RANDOM_UPC"
}
}
]
}
}
}
works just fine. However, when using the Java API, I have prepared an identical UpsertCatalogObjectRequest
instance which I am sending by calling upsertCatalogObjectAsync
and it throws an ExecutionException
, with an embedded APIException
instance whose message is the rather uninformative com.squareup.square.exceptions.ApiException: HTTP Response Not OK
.
If you check the screenshots below from my IDE, which are taken right before I make that call, I believe that the contents of the UpserCatalogObjectRequest
I am forming are exactly the same as those in the curl
request above.
Here you can see the entire UpsertCatalogObjectRequest
instance:
Here you can see the CatalogItem
that is embedded within the CatalogObject
inside the UpsertCatalogObjectRequest
:
And, finally, here you can see the CatalogItemVariation
field that is embedded within the CatalogItem
:
(Note: the priceMoney
field is not showing under the CatalogItemVariation
information, but I can assure you that it has the exact same values as the curl
payload above).
What am I doing wrong here? I should also say that at some random point this morning, the same Java upsert call actually went through just fine, but every other time I’ve tried it today I get the same exception, with the curl
working just fine.
If it is in any way important, the app that I am testing is called caliskunk
, it has Sandbox application id: sandbox-sq0idb-4jMU5yV5e77-2cqM9IxHEA
and the sandbox account is Caliskunk - Sandbox
. Thank you for your help with all of my concerns, it really means a lot.