Search code examples
xero-api

Xero API, Can send an Invoice but I can't send a Credit note, get error "Message": "Invoice not of valid type for creation"


Sorry, I am new to this, so this may sound a bit silly. We have a very basic Xero API that seems to work fine for other installs For a new Client, I have hit this brick wall. Via the Xero API We can send an Invoice ACCREC to say AccountCode 131.2 But we cannot send a Credit Note ACCRECCREDIT to AccountCode 131.2

We get this error every time "ValidationErrors": [ { "Message": "Invoice not of valid type for creation" } ], "Warnings": [ { **"Message": "Account code 131.01 has been removed as it does not match a recognised **account."``

But that Account code does exist! as I have just posted an Invoice to it! I have tried this with Client Xero and now my own Xero

So what am I missing?

Here is the XML I am sending

<CreditNote>
    <Type>ACCRECCREDIT</Type>
<CreditNoteNumber>CR001</CreditNoteNumber>
<Date>2022-12-22</Date>
<CurrencyCode>NZD</CurrencyCode>
<CurrencyRate>1.0000</CurrencyRate>
<LineAmountTypes>Exclusive</LineAmountTypes>
<SubTotal>1283.66</SubTotal>
<TotalTax>192.55</TotalTax>
<Total>1476.21</Total>
<Contact>
    <Name>Hello World Company</Name>
    <Addresses>
        <Address>
            <AddressType>POBOX</AddressType>
        </Address>
    </Addresses>
</Contact>
<LineItems>
    <Description>Sales</Description>
    <Quantity>1</Quantity>
    <UnitAmount>1283.66</UnitAmount>
    <AccountCode>131.01</AccountCode>
</LineItems>
</CreditNote>

Thanks in advance

I have tried 2 different Xero accounts I have tried various Account Codes I have tried many different versions of the XML


Solution

  • What url are you using to send the call? Credit notes have their own endpoint so you need to use https://api.xero.com/api.xro/2.0/CreditNotes