Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Find a Developer >

Account code '200' is not a valid code for this document.

Started by Yashpal Chepuri -   in Find a Developer

The payload being built this way..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Invoices>

<Invoice>

<Contact>

<Name>Joness dave</Name>
<UpdatedDateUTC xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

</Contact>
<Date>2013-09-24T11:04:00.499+05:30</Date>
<DueDate>2013-09-24T11:04:00.499+05:30</DueDate>
<Status>SUBMITTED</Status>
<LineItems>


<LineItem>

<Description>During Title Loan</Description>
<UnitAmount>500.00</UnitAmount>
<TaxType>INPUT</TaxType>
<TaxAmount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LineAmount>1000.00</LineAmount>
<AccountCode>200</AccountCode>
<Quantity>2</Quantity>

</LineItem>


</LineItems>
<SubTotal>1000</SubTotal>
<TotalTax>50</TotalTax>
<Total>1050</Total>
<UpdatedDateUTC xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<CurrencyCode>USD</CurrencyCode>
<FullyPaidOnDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<Type>ACCREC</Type>
<InvoiceNumber>123456</InvoiceNumber>
<Reference>reference</Reference>
<TotalDiscount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

</Invoice>

</Invoices>



and the response was



<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>10</ErrorNumber>
<Type>ValidationException</Type>
<Message>A validation exception occurred</Message>
<Elements>
<DataContractBase xsi:type="Invoice">
<ValidationErrors>
<ValidationError>
<Message>Account code '200' is not a valid code for this document.</Message>
</ValidationError>
</ValidationErrors>
<Warnings />
<Contact>
<ValidationErrors />
<Warnings />
<ContactID>6f24e444-56a6-4525-b2f7-0b391e764667</ContactID>
<Name>Joness dave</Name>
<Addresses />
<Phones />
<UpdatedDateUTC xsi:nil="true" />
<ContactGroups />
<IsSupplier xsi:nil="true" />
<IsCustomer xsi:nil="true" />
<Discount xsi:nil="true" />
</Contact>
<Date>2013-09-24T17:34:00</Date>
<DueDate>2013-09-24T17:34:00</DueDate>
<BrandingThemeID xsi:nil="true" />
<Status>SUBMITTED</Status>
<LineAmountTypes>Exclusive</LineAmountTypes>
<LineItems>
<LineItem>
<ValidationErrors />
<Warnings />
<Description>During Title Loan</Description>
<UnitAmount>500.00</UnitAmount>
<TaxType>INPUT</TaxType>
<TaxAmount xsi:nil="true" />
<LineAmount>1000.00</LineAmount>
<AccountCode>ACTIVE</AccountCode>
<Tracking />
<Quantity>2.0000</Quantity>
<DiscountRate xsi:nil="true" />
</LineItem>
</LineItems>
<SubTotal>1000.00</SubTotal>
<TotalTax>50.00</TotalTax>
<Total>1050.00</Total>
<UpdatedDateUTC xsi:nil="true" />
<CurrencyCode>USD</CurrencyCode>
<FullyPaidOnDate xsi:nil="true" />
<Type>ACCREC</Type>
<InvoiceID>00000000-0000-0000-0000-000000000000</InvoiceID>
<InvoiceNumber>123456</InvoiceNumber>
<Reference>reference</Reference>
<Payments />
<CreditNotes />
<AmountDue xsi:nil="true" />
<AmountPaid xsi:nil="true&
@Yashpal - I suggest you check out the API Reference that has some good examples for the minimum request XML. If you use the API Previewer - there are some great examples there too

Most apps don't need to specify the TaxType for line items. Each AccountCode in Xero has a default tax type and this is set automatically for API calls. In the case above you're trying to use a revenue account code with a tax rate for expenses. If you use GET Accounts you'll find that revenue accounts use a TaxType that start with OUTPUT in most cases.
 

Tony Rule (Xero Staff)  

Hi Tony Rule,

Thanks for the reply.
minimal XML being submitted by me

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Invoices>
<Invoice>
<Contact>
<Name>Joness dave</Name>
<UpdatedDateUTC xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</Contact>
<Date>2013-09-25T10:41:59.125+05:30</Date>
<DueDate>2013-09-25T10:41:59.125+05:30</DueDate>
<LineItems>
<LineItem>
<Description>During Title Loan</Description>
<UnitAmount>500.00</UnitAmount>
<TaxAmount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LineAmount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<AccountCode>200</AccountCode>
<Quantity>2</Quantity>
</LineItem>
</LineItems>
<SubTotal xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<TotalTax xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<Total xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<UpdatedDateUTC xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<FullyPaidOnDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<Type>ACCREC</Type>
<TotalDiscount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</Invoice>
</Invoices>

response i got was...

<ApiException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ErrorNumber>10</ErrorNumber>
<Type>ValidationException</Type>
<Message>A validation exception occurred</Message>
<Elements>
<DataContractBase xsi:type="Invoice">
<ValidationErrors>
<ValidationError>
<Message>The line total does not match the expected line total 1000.00</Message>
</ValidationError>
</ValidationErrors>
</DataContractBase>
</Elements>
</ApiException>


Please help.

Regards,
Srinath.
 

Yashpal Chepuri  

Hi Yashpal

If you remove the following lines from your request this will resolve the issue

<TaxAmount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LineAmount xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

Regards,
Tony
 

Tony Rule (Xero Staff)  

Hi Tony,

I've removed those tags and hit the service, got this problem now...
<ValidationError>
<Message>The line total does not match the expected line total 1000.00</Message>
</ValidationError>

Help me.

Thanks,
Srinath.
 

Yashpal Chepuri  

@Srinath - looks like the same validation error - the LineAmount element is still being specified in your request. I suggest you try using the API Previewer and start with a basic request and make modifications from there.
 

Tony Rule (Xero Staff)  

Hi,
request XML..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExpenseClaims>
<ExpenseClaim>
<User>
<UserID>00000000-0000-0000-0000-000000000000</UserID>
</User>
<Receipts>
<Receipt>
<ReceiptID>00000000-0000-0000-0000-000000000002</ReceiptID>
<SubTotal xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<TotalTax xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<Total xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</Receipt>
</Receipts>
</ExpenseClaim>
</ExpenseClaims>
Thanks in advance.
 

Yashpal Chepuri  

Hi,
this is what i got in response for the above request..
<Message>A valid user should be identified using the UserID.</Message>
<Message>Receipt cannot be found using the specified ReceiptID</Message>

could you help me, what values should <UserID> and <ReceiptID> tags hold.

thanks in advance.
 

Yashpal Chepuri  

go to chart of account and create an account with account code 200 or update any account with account code 200
 

Ramakrishna Reddy