Xero add attachement to invoice

  • n8n version: 1.71.0
  • **Database (default: SQLite):**SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Win 10

Hi guys,

I have an http request to add an attachment to a xero invoice. I am using Credential Type = Xero OAuth2 API
which has 4 scopes available for Xero

I have also added the following header parameter (these should cover adding an attachment)

scope = 
accounting.attachments invoices files offline_access accounting.transactions openid profile email accounting.contacts accounting.settings

I call the webhook from postman with a csv in the body.

I get the reply

{
    "body": {
        "Type": null,
        "Title": "Unauthorized",
        "Status": 401,
        "Detail": "AuthorizationUnsuccessful",
        "Instance": "15471d5b-3ca8-4377-a11c-d1a7c5fcece7",
        "Extensions": {}
    },
    "headers": {
        "content-type": "application/json",
        "content-length": "152",
        "server": "nginx",
        "www-authenticate": "insufficient_scope",
        "xero-correlation-id": "15471d5b-3ca8-4377-a11c-d1a7c5fcece7",
        "x-appminlimit-remaining": "9999",
        "expires": "Tue, 14 Jan 2025 15:18:35 GMT",
        "cache-control": "max-age=0, no-cache, no-store",
        "pragma": "no-cache",
        "date": "Tue, 14 Jan 2025 15:18:35 GMT",
        "connection": "close",
        "x-client-tls-ver": "tls1.3"
    },
    "statusCode": 401,
    "statusMessage": "Unauthorized"
}

Does this mean the credentials only allow the 4 scopes and I cannot add further scopes ?

  1. Am I adding the scopes correctly
  2. How do I achieve adding the attachment please?

Hi @Steve_Warburton

You cannot add scopes like that. It needs to be done in the credentials.
As the Xero credentials do not have this scope you will need to create a seperate Oauth2 credential including the needed scopes.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.