Occasionally when POSTing to the API you might come across the Error 409 - Incorrect Rowversion. If you do then here are a few things to check with your API call to insure that it is a successful call:
1. Ensure that you are using the right HTTP method for what you are trying to achieve with your API call.
The MYOB Business API supports 4 different HTTP Methods - GET, POST, PUT & DELETE. The two that often get confused are PUT & POST.
If you are wanting to create a new transaction via the API where the data does not already exist in the MYOB company file then the HTTP Method you would use is POST.
Where as If you are simply just updating a transaction that already exists in the file, then the HTTP Method that you would use is PUT.
2. Make sure that when POSTing, you are not passing the UID field for the transaction that you are trying to create.
What is means is the master UID for the transaction is created by the MYOB company file when the API call is made so this does not need to be provided. If you provide this , then it will cause a conflict and result in the error 409.
We recommend that rather that passing the UID field as null, this field be removed all together in a POST request.
See the example at the end of this article of how the MYOB Business API would expect to receive a request body of a POST call for the /Sale/Invoice/Service endpoint.
3. The RowID and RowVerison fields should not be passed when doing a POST request.
Same as the master UID field for the transaction, the RowID and RowVerison fields should not be provided when creating a POST request.
We recommend that they be removed from the request all together. The Company file will automatically create these entries and the API will pass them back if you need to retrieve them after the transaction has been created.
See the example at the end of this article of how the MYOB Business API would expect to receive a request body of a POST call for the /Sale/Invoice/Service endpoint.
Example of a request body of a POST call for the /Sale/Invoice/Service endpoint:
{
"Number": "00000024",
"Date": "2021-07-31T00:00:00",
"Customer": {
"UID": "a1faca5b-7797-4b05-92e8-bc11116b8c6b"
},
"Lines": [
{
"Type": "Transaction",
"Description": "Planned service per schedule - Coolers",
"Total": 175.500000,
"Account": {
"UID": "b1a6f7d4-4366-4f61-9aad-d420b581d994"
},
"Job": {
"UID": "3837fbec-2f74-4003-b8c7-d97d98ba8a97"
},
"TaxCode": {
"UID": "62324ffa-0dd0-4429-bdb0-623289f1216d"
}
}
],
"Terms": {
"PaymentIsDue": "DayOfMonthAfterEOM",
"DiscountDate": 1,
"BalanceDueDate": 30,
"DiscountForEarlyPayment": 0.0,
"MonthlyChargeForLatePayment": 0.0,
"DiscountExpiryDate": "2021-08-01T00:00:00",
"Discount": 0.0,
"DiscountForeign": null,
"DueDate": "2019-08-30T00:00:00",
"FinanceCharge": 0.0,
"FinanceChargeForeign": null
},
"IsTaxInclusive": true,
"SubtotalForeign": null,
"Freight": 0.000000,
"FreightForeign": null,
"FreightTaxCode": {
"UID": "62324ffa-0dd0-4429-bdb0-623289f1216d"
},
"Category": null,
"Salesperson": {
"UID": "94d4b286-afb8-420d-b29b-b3c69412581d"
}
}
Comments
0 comments
Article is closed for comments.