Forum Discussion

benjii's avatar
5 years ago

Updating an invoice (via UID)

Hi,

 

So we am trying to update an invoice via the MYOB AccountRight Live API. Our platform has a use-case where, after an invoice is created, it can be updated.

 

And so, when our platform creates an invoice we need to be able to link to it (store some kind of identifier in our database) so that we can update it later. A UID would be ideal, however, neither the UID that we set during create (POST) seems applied to the invoice in MYOB, nor do we recieve a UID back. We get an empty body in the response.

 

And so what we have done is use oData queries to get back to the original invoice. Like this:

 

${companyFileUri}/Sale/Invoice/Service/?$filter=Number eq '${formattedInvoiceNumber}' and Customer/UID eq guid'${customerUid}'

 

This works but seems a bit "brittle". It seems very, very unlikely that there would ever be a customer with invoices with the same number, but I suppose it is possible. If we had a UID we would be able to guarantee uniqueness.

 

Have I missed something here? It seems if MYOB were to pass back the UID that it generates for a new invoice we'd be golden.

 

Thanks for your time.

 

Kind regards,

Ben

  • It's not documented well, but if you pass ?returnBody=true in the request, it will return the new GUID (alongside all other details) and you can then store it for reference. Found that out through experimentation

    • Thank you Yendall. This worked perfectly for me. I appreciate that you took the time to reply and help me out. :)

      Cheers,

      Ben