Skip to content
Advertisement

XERO PHP SDK – Createinvoiceattachment throws 401 Unauthorized error

I am trying to attach a document to an invoice. It throws the error. The tenant id, invoice id are correct.

Exception when calling AccountingApi->createInvoiceAttachmentByFileName: [401] Client error: PUT https://api.xero.com/api.xro/2.0/Invoices/b03b18ca-50b2-42fa-a585-aa5674b7ed03/Attachments/2New-Requirment-Oct2020.docx?IncludeOnline=true resulted in a 401 Unauthorized response: {“Type”:null,”Title”:”Unauthorized”,”Status”:401,”Detail”:”AuthorizationUnsuccessful”,”Instance”:”54c33c01-e168-47d5-abe (truncated…)

My Code is:

JavaScript

Advertisement

Answer

Attachments require different scopes to use.

Have you included the ‘accounting.attachments’ scope in the scopes requested when authorising the connection?

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement