question

jharna27 avatar image
jharna27 asked David Marginian Deactivated commented

Sandbox 502 Bad Gateway Error when adding modifiers

I face a 502 error when I am trying to add modifiers to the lineItems of an order using python+REST API. Also, when I try out the same in the API Resources by entering the details - it throws a 400 Bad Request error (Request needs a modifier object). Even though I am essentially adding all details. I have attached the code below. Requesting your help.

url = "https://sandbox.dev.clover.com//v3/merchants/"+muuid+"/orders/"+orderID+"/line_items/"+lineitem+"/modifications"


payload = {
  "modifier": {
    "modifierGroup": {
      "id": "WBG8RG2N2GPPA"
    },
    "name": "Beer",
    "price": 500
  }
}
headers = {
  'Authorization': 'Bearer' + bearerID,
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))


OrdersLineItemsModifiers
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented

Perhaps you are getting the 502 because you have an extra / in the url. For the 400, you need to pass the id of an existing modifier (and drop the name/price). That endpoint adds a modifier to a lineitem, it doesn't create the modifier. https://docs.clover.com/docs/working-with-orders. Our API docs are incorrect, they don't show id as required (and show name/price as required, which is not correct). The current documentation is misleading/confusing and I have created an issue to investigate/fix it.

3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jharna27 avatar image jharna27 commented ·

Hi David, I corrected the url and passed the payload as mentioned by you. Even when I pass an existing modifier ID, it returns "Modifier not found". When it is infact a modifier present in the inventory.

0 Likes 0 ·
jharna27 avatar image jharna27 jharna27 commented ·

Hi David, it worked! It seems I was trying to pass the modifier group ID + modifier name instead. The documentation didn't mention that getting the modifier ID is required, plus in the sandbox inventory, there is no way to get the modifier ID for testing purposes.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ jharna27 commented ·

Unfortunately there are some known issues with our REST API documentation and they aren't trivial to solve. I am glad you got it working.

0 Likes 0 ·

Welcome to the
Clover Developer Community