question

robsmitha avatar image
robsmitha asked jms edited

How to save userData on LineItem using the /v3/merchants/mId/orders/orderId/line_items REST API endpoint?

I am using the /v3/merchants/mId/orders/orderId/line_items API endpoint to save a serialized json object in the userData property. The data type is a string and the response comes back as successful, but when I load the line item as an expansion on the /v3/merchants/mId/orders/orderId?expand=lineItems endpoint, it shows the userData property as null.

Is there an expansion or certain endpoint I need to be using to get the userData of a line item?

Thanks.
REST APILineItems
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.

robsmitha avatar image robsmitha commented ·

Here's the json string that I am attempting to save in the userData property.

"{\"reservationId\":2581,\"cloverOrderId\":\"RHQ9CDB9W5CE6\",\"cloverLineItemId\":\"EVT8RKYJQDB4T\"}"

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

Did you verify the userData saved by querying for the line item directly instead of via the orders endpoint?

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

Yes, I used this endpoint "/v3/merchants/GRQX6PQ7JGRN4/orders/ZJZJ0ZVGRHR60/line_items/R69RCCFQYMPWC" to get the single line item and the userData is still null. It appears the userData is not saving with this endpoint: /v3/merchants/mId/orders/orderId/line_items

Here is an example of a previous request that came back as status OK:

{\"id\":null,\"orderRef\":null,\"orderId\":null,\"item\":{\"id\":\"9KWK8RAJETPQT\"},\"name\":\"Reservation Cancel\",\"price\":550,\"printed\":false,\"createdTime\":0,\"orderClientCreatedTime\":0,\"exchanged\":false,\"refunded\":false,\"isRevenue\":false,\"userData\":\"{\\\"reservationId\\\":2401,\\\"cloverOrderId\\\":\\\"DC00A8REBG7KE\\\",\\\"cloverLineItemId\\\":\\\"NVAAWQHFSNZH0\\\"}\"}
0 Likes 0 ·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented
It looks like this may be a bug, I will create an internal issue so someone that works in this area can investigate.
2 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.

robsmitha avatar image robsmitha commented ·

Thanks for your help. FYI, update allows me to save the userData on an existing line item, but I'd prefer to do it on create to limit my api calls.

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

Ok, it's good that you have a work-around for now. I did briefly look at the code and couldn't determine why it isn't working but I don't work on the REST API.

0 Likes 0 ·
willwoodberybrandt avatar image
willwoodberybrandt answered David Marginian Deactivated commented

Has this bug been resolved?

1 comment
10 |2000

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

David Marginian avatar image David Marginian ♦♦ commented ·

The issue is still open, so it looks like it has not. You will have to use the work-around of using update.

0 Likes 0 ·
jms avatar image
jms answered

Apparently this works using the bulk line items endpoint:

https://docs.clover.com/reference#orderbulkcreatelineitems-2

However, as OP said, it does not work for the normal single line item creation endpoint:
https://docs.clover.com/reference#ordercreatelineitem-2

You could consider using the bulk line item endpoint to reduce the amount of requests you make to clover end in this case (as long as all your properties are supported by this endpoint)

10 |2000

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

pttommy avatar image
pttommy answered jms edited

The atomic order API has the same issue. In our case updating it after creation doesn't work, as we don't know which order item to assign which user data (as the IDs are generated by Clover).

2 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.

jms avatar image jms commented ·
Yep, can confirm this as well. We just had a use case for this and are now thwarted at our attempts.

Would be great if this was resolved. Seems the issue has been open since 2019.

0 Likes 0 ·
jms avatar image jms commented ·

Hi @pttommy. You can actually correlate the index of the line items placed on Clover end with the order of items on your end. Clover preserves the order of lineItems you add to it (its not the best but it's the only workaround I see here)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community