Cannot update orders in orderapi

I’m trying to add lineitems to orders (transactions) using the orders-api and I keep getting a “FORBIDDEN” error.

What’s your application ID? Also is this with an OAuth’d account? :slightly_smiling_face:

Application ID: sq0idp-1W0thNjdxLzN6e649E95Yg
No I was using an Access Token

Looking at your API Logs it looks like you were calling sandbox with that order_id. That order is a production order which is why you got the FORBIDDEN error. You’ll need to call the production environment to update the order. :slightly_smiling_face:

Oh I thought I was calling the production environment. I’m now getting a VERSION_MISMATCH error

Okay, great! Yeah, you’ll need to make sure you pass in the current version of the order. :slightly_smiling_face:

1 Like

So I keep this forbidden error:

I’ve doubled checked and I’m for sure using production info to create and edit the order

Currently with Square orders the location_id isn’t a field that can be updated. :slightly_smiling_face:

Oh I wasn’t trying to update the location_id, just said it was required so I put it

Okay, I didn’t see anything else in the request. What fields of the order are you trying to update? Also have you tried our API Explorer to build requests? :slightly_smiling_face:

Yep, I’m using the API Explorer. And I’m trying to update orders to have line items on them, since I’m using the sdk reader and it doesn’t allow for line items

Okay, orders from payments with Reader SDK even if they’re in an AUTHORIZED state aren’t able to be updated with UpdateOrder. :slightly_smiling_face:

Ok, so does that mean orders created with the delayCapture flag to true aren’t able to be updated also?

That is correct. Only orders that were processed with the Payments API with autocomplete set to false are able to be updated. :slightly_smiling_face:

1 Like

Ok, thank you Bryan, you’ve been a ton of help

Is there any way to have the reader sdk have a line item on it so that we can deplete an inventory item amount per transaction?

The only way for it to have a line item is to pass in a note. If all the items in your Catalog have user_data then you can use that as a reference_id.

Basically your app is allowing the seller to select items you can use your own custom user_data of each item they’re selling and pass that in as a note. When the payment is processed your service can query the note for all the user_data. Then SearchCatalogObjects with:

{
  "object_types": [
    "ITEM", "ITEM_VARIATION"
  ],
  "query": {
    "prefix_query": {
      "attribute_name": "user_data",
      "attribute_prefix": "my_custom_reference_id"
    }
  },
  "limit": 100
}

You’ll get back the item_variation and can them make necessary inventory updates. :slightly_smiling_face:

1 Like

Thanks Bryan, I’ll try that out