question

Nirmal avatar image
Nirmal asked ·

status code 400 when adding modifier to line item clover

I am adding some custom line item to order . I need to add some custom modifier to recognize item later. When i m adding modifier with line item id and order id i am getting status code 400 error.

Custom Modifiers
2 comments
10 |2000 characters needed characters left characters exceeded

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

Hi,

Will you provide the request URI + request body? A screenshot from a REST API client like Postman would be helpful.

0 Likes 0 · ·

Hii I am using android SDK and using following code snippet :-

LineItem lineItem= mOrderConnector.addCustomLineItem(orderId, mItem, false); Modifier modifier= new Modifier(); modifier.setName("Demo"); mOrderConnector.addLineItemModification(orderId, lineitem.getId(), modifier);

0 Likes 0 · ·
Dan avatar image
Dan answered ·

I believe that the modification that you add to a line item has to be a proper modifier in the merchant's inventor (can't make a one-off custom modification). Try adding a modifier with the uuid provided by InventoryConnector#getModifierGroups(...) and InventoryConnector.getModifiers(...).

Alternatively, could use InventoryConnector#createModifierGroup(...) and InventoryConnector#createModifier(...), and once it is persisted to the database you can get the proper modifier uuid and then should be able to add it to the order (don't actually do this for each order though).

2 comments Share
10 |2000 characters needed characters left characters exceeded

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

Converting to Answer... this is what you're looking for @Nirmal. Thanks @dan.

0 Likes 0 · ·

Keep in mind that you'll need to modifier.setPrice() to be able to persist it to the db - it looks like in your example code @Nirmal that a price was not set. Price is a required property for a Modifier.

0 Likes 0 · ·
Mark Mullan avatar image
Mark Mullan answered ·

Hi @Nirmal,

A Modifier is associated with an Item, and a Modification is associated with a LineItem. Looks like you're instantiating a Modifier and trying to associate it with a LineItem. Let me know if this information helps you resolve the issue.

1 comment Share
10 |2000 characters needed characters left characters exceeded

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

Can you please elaborate the same so i can rectify this

0 Likes 0 · ·

Welcome to the
Clover Developer Community