square/connect-php-sdk

500 Internal Server Error comes when use production mode to upsertCatalogObjects

manly0305 opened this issue · 2 comments

I want update my ITEM VARIATION use the API . But the following error comes out
both batch-upsert and upsert

(1/1) ApiException
[HTTP/1.1 500 Internal Server Error] {"errors":[{"category":"API_ERROR","code":"INTERNAL_SERVER_ERROR","detail":"An internal error has occurred, and the API was unable to service your request."}]}

in ApiClient.php line 236
at ApiClient->callApi('/v2/catalog/batch-upsert', 'POST', array(), '{"idempotency_key":"5e1d7e7f93e49","batches":[{"objects":[{"id":"V2ZW53BRLKEBNJLSJVT3VISN","type":"ITEM_VARIATION","item_variation_data":{"inventory_alert_type":"LOW_QUANTITY","inventory_alert_threshold":3,"name":"#1B Natural Black \\/ 12 Inch","price_money":{"amount":7898,"currency":"USD"},"pricing_type":"FIXED_PRICING","track_inventory":true},"version":1578730492189}]}]}', array('Accept' => 'application/json', 'Content-Type' => 'application/json', 'Square-Version' => '2019-12-17', 'Authorization' => 'Bearer {{access_token_redacted}}'), '\\SquareConnect\\Model\\BatchUpsertCatalogObjectsResponse')
in CatalogApi.php line 328

Hey @manly0305 thanks for reporting this. We definitely shouldn't be reporting a 500 internal error, so I've reported this to our Catalog team.

In the mean time, I was able to find the logs with the catalog object id you provided, and it looks like this error is stemming from a missing item_id within the item_variation_data field. You need to include the item_id so it knows what item this variation belongs to.

One last thing: please replace your access token, as that is private information and anyone with that token can access your account via APIs. Please never share the token with anyone, including Square employees. I've edited it to remove it from your original post, but I still highly suggest it be replaced. Thanks!

The error should be resolved, now, and should return a 400 instead. Please comment if you have additional questions or concerns.