Have built a workflow automation microservice to import an order for a specific customer in CETEC using the POST [https://xxxxxxxx.cetecerp.com/api/importjson] endpoint. In order to do this we need the customer_id
.
The microservice obtains the customer_id
by searching for the customer with CETEC API using the GET [https://xxxxxx.cetecerp.com/api/customer] endpoint by acct_email
. Where a customer is not found the microservice creates a new customer using the PUT [https://xxxxxxxx.cetecerp.com/api/customer] endpoint which returns the customer_id
.
The above works very well, untill we create a new customer (by virtue email address not being found in CETEC customer list) who has the same name as an existing customer. In this case, because we’re using the PUT verb the CETEC API updates the customer with matching name and returns the customer_id
of that customer with matching name - yet these are different customers with the same name. Thereby, the order is added to the wrong customer.
Why does the CETEC API have to create a customer using PUT instead of POST. If the endpoint requirement is to create a new customer if the customer is not found, why is the API matching by name which is not a unique identifier instead of unique attributes like email address or phone number?
In my view the current CETEC API is more difficult to use. Currently thinking of a workaround to overcome this caveat, and greatly appreciate your assistance on how you would implement our use case with the current CETEC API?