Xero API InvalidAttachment error when adding attachments to invoices using Xero API.

The attachment format or size is not supported.

Debug error automatically with DrDroid AI →

Connect your tools and ask AI to solve it for you

Try DrDroid AI

Understanding Xero API

Xero API is a powerful tool designed for developers to integrate Xero's accounting software capabilities into their applications. It allows for seamless management of financial data, including invoicing, payments, and more, directly from your application.

Identifying the Symptom

When using the Xero API, you might encounter an InvalidAttachment error. This error typically occurs when attempting to add an attachment to an invoice, and it indicates that there is an issue with the attachment being uploaded.

Common Error Message

The error message usually reads: 'InvalidAttachment: The attachment format or size is not supported.'

Exploring the Issue

The InvalidAttachment error is triggered when the file you are trying to attach does not meet Xero's requirements. This can be due to unsupported file formats or exceeding the maximum file size limit.

Supported Formats and Size Limits

Xero supports common file formats such as PDF, JPG, and PNG. The maximum file size for attachments is typically 3MB. Exceeding this limit or using an unsupported format will result in an error.

Steps to Fix the Issue

To resolve the InvalidAttachment error, follow these steps:

Step 1: Verify File Format

Ensure that the file you are trying to attach is in a supported format. Convert the file to a supported format if necessary. You can use tools like Adobe's PDF to JPG converter for conversion.

Step 2: Check File Size

Confirm that the file size does not exceed the 3MB limit. If it does, reduce the file size using compression tools. Online tools like iLovePDF can help compress PDF files.

Step 3: Update API Request

Once the file is in the correct format and size, update your API request to include the corrected file. Ensure your API call is structured correctly, as shown in the Xero API documentation.

Conclusion

By ensuring your attachments meet Xero's format and size requirements, you can effectively resolve the InvalidAttachment error. Regularly checking the Xero API limits will help prevent similar issues in the future.

Get root cause analysis in minutes

  • Connect your existing monitoring tools
  • Ask AI to debug issues automatically
  • Get root cause analysis in minutes
Try DrDroid AI