Create Invoice with REST API
Hi all,
Has anyone successfully created an invoice using the REST API? The documentation is pretty sparse on payload examples and the closest approximation in the postman collection is Create Sales Order. Using the schema of the postman Create Sales Order as a starting point for invoices isn’t working, I’m just getting a 400 “Invalid content in the request body.” error.
My current test payload (with id’s redacted) is:
A solid strategy is to do a get on an existing invoice, then strip away all the fields you dont want to set and use that as a template to create your invoice.
A more metadata based approach is to use something like https://editor.swagger.io/ to see what an example request could look like by inputting the invoice metadata.
Thanks battk! using the swagger editor with the metadata from the table was definitely the way to go. It gives sample payloads for each endpoint.
Hello, you can use this structure. It’s work well!
{
“account”: {
“id”: “xxx”,
“refName”: “xxx Accounts Receivables : Accounts Receivable”
},
“item”: {
“items”: [
{
“item”: {
“id”: “xxxx”,
“type”: “noninventorysaleitem”
},
“amount”: 2.0,
“quantity”: 2.0
}
]
},
“currency”: {
“id”: “1”,
“refName”: “Australian Dollar”
},
“customForm”: {
“id”: “xxx”,
“refName”: “KxxxxV ANZ xxx STD – Invoice”
},
“email”: “xxx@xxx.com”,
“entity”: {
“id”: “xxx”,
“refName”: “xxxx Test x xxname”
},
“exchangeRate”: 1.0,
“excludeFromGLNumbering”: false,
“location”: {
“id”: “41”,
“refName”: “AUS : ACT : xxxxx ACT”
},
“postingPeriod”: {
“id”: “121”,
“refName”: “Aug 2021”
},
“subsidiary”: {
“id”: “19”,
“refName”: “x xxx Pty Limited”
},
“subtotal”: 2.0,
“terms”: {
“id”: “13”,
“refName”: “14 Days EOM”
},
“toBeEmailed”: true,
“tranDate”: “2021-08-11”
}