"BAD_REQUEST" - "sake INVALID_REQUEST" error when calling InventoryAPI inventory/batch-change

Hi,

I’m trying to do a batch inventory update using the REST API:

POST https://connect.squareup.com/v2/inventory/batch-change

 {
 	"idempotency_key": "8fckenfioq3j4ifoi3j4iogfq3ajeigrne",
 	"changes": [
 	  {
 	    "type": "ADJUSTMENT",
 	    "adjustment": {
 	      "catalog_object_id": "3SZHUFZS22RTUDSWEOK4BGHR",
 	      "from_state": "IN_STOCK",
 	      "to_state": "SOLD",
 	      "location_id": "NR0CGEEEYTSDX",
 	      "quantity": "-3",
 	      "occurred_at": "2020-04-24T11:31:59-04:00"
 	    }
 	  }
 	]
 }

But, I am running into this error which I can’t find any info about on Google, and the error detail is cryptic:

{
     "errors": [
         {
             "category": "INVALID_REQUEST_ERROR",
             "code": "BAD_REQUEST",
             "detail": "sake INVALID_REQUEST: sake INVALID_REQUEST: "
         }
     ]
}

I’ve added INVENTORY_WRITE permission to the app. I’ve also been able to make other api calls without any issue.

Does anyone know what I’m doing wrong?

Hey @jroc, welcome to the forums.

I’ll relay this to our inventory team, as that’s a pretty bad error response. Looking at the logs, the actual error is due to the quantity field being negative. It always has to be a positive integer, and the states will decide on whether it adds or removes stock.

Perfect, that worked great. Thanks @sjosey!