I posted to create an order, then tried adding a customer by posting to that order's url with
{"customers":[{"id": "a customer id"}]}
as the body. But the customer does not seem to be associated with the order, eg, when I get the order with expand=customers
.
How can I associate a customer with an order through the REST API?
EDIT: The create call with {"state": "open"} is working fine. Here is the update call I'm making (using a bit of clojure notation, but I'll edit it if it isn't clear):
{:query-params {:expand "lineItems,customers,discounts"},
:headers {"Authorization" "Bearer [redacted]",
"Content-Type" "application/json"},
:body "{\"customers\":[{\"id\":\"P66PMHWPYATD6\"}]}",
:method :post,
:url "https://apisandbox.dev.clover.com/v3/merchants/BQJ0X97C7Y6R0/orders/"}
And the response body:
{"clientCreatedTime" 1447295250000,
"manualTransaction" false,
"currency" "USD",
"groupLineItems" true,
"id" "GQY6HNYM2ZFD8",
"createdTime" 1447295250000,
"href" "https://sandbox.dev.clover.com/v3/merchants/BQJ0X97C7Y6R0/orders/GQY6HNYM2ZFD8",
"isVat" false,
"modifiedTime" 1447295250000,
"testMode" false,
"taxRemoved" false}
And getting that order with expand=customers
through the API confirms that the order has no customers.
If I get https://apisandbox.dev.clover.com/v3/... the response is
{"href": "https://sandbox.dev.clover.com/v3/merchants/BQJ0X97C7Y6R0/customers/P66PMHWPYATD6",
"id": "P66PMHWPYATD6",
"firstName": "fae",
"marketingAllowed": false,
"customerSince": 1447204452000}
So the customer is there.
EDIT 2: I was posting to the wrong route. I didn't get the order id from the response properly and wound up with nil
, concatenated it on to the order url, and got /v3/merchants/BQJ0X97C7Y6R0/orders/
instead of /v3/merchants/BQJ0X97C7Y6R0/orders/GQY6HNYM2ZFD8
, which was still a valid URL to post to, so I missed the error.