How to download a Microsoft Sharepoint file with the HTTP node

Having issues downloading a file from my sharepoint tenant. I’m trying to use the HTTP node with my MS teams OAuth credentials (I’ve given the app registration the Sharepoint Sites.ReadWrite.All scope) but am getting an UNAUTHORIZED error.

What is the error message (if any)? - UNAUTHORIZED 401

Please share your workflow

“meta”: {
“instanceId”: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa""
“nodes”: [
“parameters”: {
“url”: “={{ $json.attachments[0].contentUrl }}”,
“authentication”: “predefinedCredentialType”,
“nodeCredentialType”: “microsoftTeamsOAuth2Api”,
“options”: {}
“id”: “2228e7c3-dad1-4014-8352-af3247b6f8b1”,
“name”: “Download Teams File”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.1,
“position”: [
“connections”: {},
“pinData”: {}

Information on your n8n setup

  • n8n version: 1.18.2
  • Database (default: SQLite): Postgresql
  • n8n EXECUTIONS_PROCESS setting (default: own, main): - queue
  • Running n8n via (Docker, npm, n8n cloud, desktop app): - EKS
  • Operating system: Linux

Hi @Hidden_Squid, I gave this a go on my side and suspect it might come down to the exact credentials setup in n8n.

Here are the settings that worked for me using a private app with custom endpoints. The credential type in use is n8n’s generic OAuth2 API credentials:

The scopes I have used are offline_access Sites.Read.All Files.Read.All User.Read (with the latter mostly for debugging).

Afterwards, downloading a file from Sharepoint works as expected for me using a workflow like this:

In this example, is my Sharepoint site ID and 01G3ZT7XO5Y4LDFSKHQZHK6EH4KCZN6I4C is the ID of my file. Result:

Hope this helps!