0

On the Xero UI, there is a way to go to the Payments made for an invoice, and add an attachment. How to do this through an API? If I try to add an attachment to the payment using the Attachments API - https://api.xero.com/api.xro/2.0/Payments/{PaymentID}/Attachments/{Filename} , I get HTTPNotFound.

But, the Payment ID does exist, as I can see it on the Xero UI, and also get the payment details through the Payments API - https://api.xero.com/api.xro/2.0/Payments/{PaymentID}

Edit : I am using the Ruby Net::HTTP for making the API call. It works when posting an attachment to invoices - https://api.xero.com/api.xro/2.0/Invoices/{InvoiceID}/Attachments/{Filename}

I am aware that their documentation - https://developer.xero.com/documentation/api/attachments - does not mention the Payments endpoint for attachments. However, the UI allows it. So, I am wondering if there is some way to do it through the API.

user3911483
  • 108
  • 10
  • u're probably using wrong method, you should use "PUT" or "POST", check this: https://stackoverflow.com/questions/630453/put-vs-post-in-rest , anyway your question is not clear enough... how do you use that API? what language? show your code – Flash Thunder Feb 12 '20 at 14:05
  • @FlashThunder I am using Ruby, Net::HTTP library to connect to Xero API. I will add more details in the question. – user3911483 Feb 12 '20 at 16:45

2 Answers2

1

You can use Xero's Files API to upload a file and create an association to a payment.

You'll need to upload the file first to https://api.xero.com/files.xro/1.0/Files - File Upload

...and then create the association by posting something like this to https://api.xero.com/files.xro/1.0/Files/{fileId}/Associations - File Associations:

{ "ObjectId":"{paymentid}", "ObjectGroup":"Payment" }

rustyskates
  • 856
  • 4
  • 10
0

Unfortunately you can't upload attachments to payments via the API.

Adam Moore
  • 371
  • 1
  • 5