question

jonl avatar image
jonl asked jonl commented

API line_items, expand employee not working?

I want to find out which employees have sold which line_items using the API

The documentation here ...

www(dot)clover(dot)com(slash)api_docs(hash)(bang)(slash)orders(slash)GetOrderLineItems

... would appear to indicate that using "?expand=employee" will return the employee that sold that item, but it does not.

Is this a documentation error, or is the API not behaving as it is supposed to.

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.

James Tickett avatar image James Tickett commented ·

[Hmm, commented by mistake and doesn't seem to be an option to remove it!]

0 Likes 0 ·
James Tickett avatar image
James Tickett answered

My guess is documentation mistake.

When you use expand, you're basically telling it: "You see this ID...? ...go fetch that related object!" So far I have only seen Employee ID used on the Order, and the Payments/Refunds. So what you may be looking for is which Employee created the Order, as they probably added those line items too, and you can find that using "?expand=order.employee" on the end of your lineitems request. Since Employee, payment, lineitems etc are all elements of the order, it might make more sense to request the Order with its employee and lineitems expanded instead.

10 |2000

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

Mike M avatar image
Mike M answered jonl commented

@JTickett is correct. The documentation is incorrect. Employees can be associated to an Order when it is first created, however, there is no relationship between the lineItems and the employee. I will open an engineering ticket to get that fixed.

I would recommend expanding employee on an Order object. /v3/merchants/{mId}/orders/{orderId}?expand=employee

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.

jonl avatar image jonl commented ·

Thanks. JTickett and mike.

I actually would have thought of expanding the Order object first, but the documentation for that API does not include "employee" in the list of expandable fields, so I didn't try that.

So make a note on that ticket that there are (at least) two places where the list of expandable fields is wrong !!

0 Likes 0 ·

Welcome to the
Clover Developer Community