JSON Create Invoice not working for multi lines

Hi,

I am writing an integration from our system to create invoices and using the following JSON to invoice/create, this works if there is a single line but fails with the below errors for multi line.

{
    "payload": {
        "Header": {
            "MessageType": "Request",
            "SubmissionNumber": "e15d4429-7465-4a84-b83d-6d604e9fd789",
            "Authentication": {
                "AccNumber": "***",
                "MD5Value": "d6c57c206597a10ca7fd296b64da576c",
                "ApplicationID": "***"
            }
        },
        "Body": {
            "InvoiceData": {
                "InvoiceType": "INVOICE",
                "ClientID": "2535938",
                "Currency": "GBP",
                "Discount": "0",
                "TermDays": "14",
                "Language": "en",
                "SingleInvoiceData": {
                    "IssueDate": "2017-05-30"
                },
                "InvoiceLines": {
                    "ItemLines": [
                        {"ItemLine": {
                                "ItemID": "0",
                                "ItemName": "0",
                                "ItemDescription": "isitchecked - June 2017",
                                "ItemNominalCode": "4000",
                                "UnitCost": "0.99",
                                "Qty": 1,
                                "Tax1": {
                                    "TaxName": "VAT",
                                    "TaxPercentage": "20.00",
                                    "TaxAmount": "0.20"
                                }
                            }
                        },
                        {
                            "ItemLine": {
                                "ItemID": "0",
                                "ItemName": "0",
                                "ItemDescription": "a.n.other - June 2017",
                                "ItemNominalCode": "4000",
                                "UnitCost": "0.99",
                                "Qty": 1,
                                "Tax1": {
                                    "TaxName": "VAT",
                                    "TaxPercentage": "20.00",
                                    "TaxAmount": "0.20"
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
}

{
  "Errors": {
    "Error": [
      "38Element 'http://www.QuickFile.co.uk:ItemLines' cannot appear more than once if content model type is \"all\".",
      "38The element 'InvoiceLines' in namespace 'http://www.QuickFile.co.uk' has invalid child element 'ItemLines' in namespace 'http://www.QuickFile.co.uk'. List of possible elements expected: 'http://www.QuickFile.co.uk:TaskLines'."
    ]
  }
}

Hi @isitchecked

Just looking over your JSON above and it looks like you have an array of ItemLines, where this should be an array of ItemLine. I’ve mocked up a small example of the part you would need to change below (different values, but similar layout):

"InvoiceLines": {
    "ItemLines": {
        "ItemLine": [{
            "ItemID": "0",
            "ItemName": "MP3",
            "ItemDescription": "MP3 Player with 16GB Memory and FM radio receiver",
            "ItemNominalCode": "4000",
            "Tax1": {
                "TaxName": "VAT",
                "TaxPercentage": "20.00",
                "TaxAmount": "10.10"
            },
            "UnitCost": "89.99",
            "Qty": "1"
        }, {
            "ItemID": "0",
            "ItemName": "MP3",
            "ItemDescription": "MP3 Track",
            "ItemNominalCode": "4000",
            "UnitCost": "3.99",
            "Qty": "5"
        }]
    }
}

Perfect - knew it would be simple!

Thanks,

Chris

1 Like

This topic was automatically closed after 7 days. New replies are no longer allowed.