MyOB AccountRight API | Updating a Customer's "specific" Address

274 views Asked by At

MyOB's AccountRight Documentation page provides a sample for Editing a Customer based on its UID & RowVersion. However, it does not cover how to update specific address records associated to that customer.

Say for example i have a customer with business name "My Business Customer" and has 5 addresses saved on it. How do i update Address #3 while keeping the original records for Addresses 1, 2, 4, and 5?

Adding only the specific updated Address Record on the Customers "Address" JSON Property removes all other address but that.

enter image description here

1

There are 1 answers

1
developerjack On

What you've described is the desire to use the PATCH HTTP verb. Unfortunately, last I checked (and as per the current docs, MYOB APIs still only support PUT which means you have to provide the full, complete JSON object as it essentially 'replaces' what's in the customers company file.

Your API calls and code would follow something similar to the following steps:

  1. GET the /Contact/Customer/{guid}
  2. Make modifications to the data (in your case, update Address 3)
  3. PUT to the /Contact/Customer/{guid} URL with your updated object.

Naturally you might not want to do this every time, so you can GET and cache the result, and use the RowVersion to determine if there's something out of date in your cache. If so, expect a HTTP 409 error because the RowVersion you provide in your PUT doesn't match the latest RowVersion of the resource in the API - but the errors will help guide you there.