Can't Send Attachment to Xero API - VB.NET

45 Views Asked by At

I have a VB.NET Project that can send invoices to Xero using the Xero API (Xero.Api.Core). It works just fine and returns an Invoice ID (GUID). I now want to add an attachment (PDF File) but cannot get this to work. No errors but just doesn't add it. There are no documentation examples on this so difficult to debug.

Here is some example code to add an attachment to an existing invoice which I am using.

Imports XeroApi.OAuth
Imports Xero.Api.Core
Dim uInvoiceID As Guid = Guid.Parse("0ba5367c-ba5c-48a3-896e-dbb4e2991606")
Dim uFileInfo = New FileInfo("C:\Users\Angus\Documents\Test RPV Report.pdf")
Dim uAttachment As New Xero.Api.Core.Model.Attachment(uFileInfo)
  uAttachment.Id = uInvoiceID
  uAttachment.IncludeOnline = False
  uAttachment.FileName = "C:\Users\Angus\Documents\Test RPV Report.pdf"
  uAttachment.Save("C:\Users\Angus\Documents\Test RPV Report.pdf")`
0

There are 0 best solutions below