8
n8n 中文网amn8n.com

使用 Microsoft Graph API 上传文件到 SharePoint

中级

这是一个Engineering, IT Ops领域的自动化工作流,包含 9 个节点。主要使用 Set, HttpRequest, ManualTrigger 等节点。 使用 Microsoft Graph API 上传文件到 SharePoint

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "97d44c78f314fab340d7a5edaf7e2c274a7fbb8a7cd138f53cc742341e706fe7",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1ec0e1ad-0666-417b-b5af-b381b06e126f",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -120,
        180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c34a92d3-b4bd-4c2f-9fa0-66832729a31c",
      "name": "上传照片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        980,
        180
      ],
      "parameters": {
        "url": "=https://graph.microsoft.com/v1.0/sites/root/drive/root:{{ $json.TARGET_FOLDER }}/{{ $json.FILE_NAME }}:/content",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.access_token }}"
            },
            {
              "name": "Content-Type",
              "value": "application/octet-stream"
            }
          ]
        },
        "inputDataFieldName": "data"
      },
      "typeVersion": 4.2
    },
    {
      "id": "49ce594c-83c7-4b47-be03-6811ebdcc57b",
      "name": "设置配置(敏感数据)",
      "type": "n8n-nodes-base.set",
      "position": [
        100,
        180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "399d42f3-41e0-4043-9a57-85771bf5cd07",
              "name": "TENANT_ID",
              "type": "string",
              "value": "00000000-0000-0000-0000-000000000000"
            },
            {
              "id": "dd63a519-3681-46c4-b122-ab379ed11c42",
              "name": "CLIENT_ID",
              "type": "string",
              "value": "00000000-0000-0000-0000-000000000000"
            },
            {
              "id": "4d50c934-c306-4198-853a-68198b8b84eb",
              "name": "CLIENT_SECRET",
              "type": "string",
              "value": "uU~8Q~THEQLIE2TX7UsecretT2g_JCADyxBxN0bx3"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "53b78aa9-d86f-461b-bff5-bd2a63a693b5",
      "name": "获取照片(用于测试目的)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        540,
        180
      ],
      "parameters": {
        "url": "https://fastly.picsum.photos/id/459/200/300.jpg?hmac=4Cn5sZqOdpuzOwSTs65XA75xvN-quC4t9rfYYyoTCEI",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "a551951c-f192-4b15-accb-ca936baef9a8",
      "name": "设置目标位置",
      "type": "n8n-nodes-base.set",
      "position": [
        760,
        180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9f66b3f9-c161-45f4-bdc0-8cf736b53eda",
              "name": "TARGET_FOLDER",
              "type": "string",
              "value": "/uploads/pictures from n8n"
            },
            {
              "id": "e8584729-2746-48a0-ad80-d0308a49e195",
              "name": "FILE_NAME",
              "type": "string",
              "value": "example.jpg"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "66129973-bf5f-4799-b676-2ee40fd2b519",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -220
      ],
      "parameters": {
        "width": 320,
        "height": 200,
        "content": "## 先决条件"
      },
      "typeVersion": 1
    },
    {
      "id": "43bbf2cd-3ac5-4c46-b3c0-bd6158dbe25e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -280
      ],
      "parameters": {
        "width": 320,
        "height": 340,
        "content": "## 身份验证"
      },
      "typeVersion": 1
    },
    {
      "id": "daa3e6b9-a9ea-4bb4-8e2d-faa516c699ea",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -280
      ],
      "parameters": {
        "width": 440,
        "height": 340,
        "content": "## 设置目标位置"
      },
      "typeVersion": 1
    },
    {
      "id": "52bd314b-6a5e-499a-904e-a7e9becbbd59",
      "name": "身份验证",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Get an access token for graph API",
      "position": [
        320,
        180
      ],
      "parameters": {
        "url": "=https://login.microsoftonline.com/{{ $json.TENANT_ID }}/oauth2/token",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "grant_type",
              "value": "client_credentials"
            },
            {
              "name": "client_id",
              "value": "={{ $json.CLIENT_ID }}"
            },
            {
              "name": "client_secret",
              "value": "={{ $json.CLIENT_SECRET }}"
            },
            {
              "name": "resource",
              "value": "https://graph.microsoft.com"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    }
  ],
  "pinData": {},
  "connections": {
    "Authentication": {
      "main": [
        [
          {
            "node": "Get photo (for testing purposes)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set destination": {
      "main": [
        [
          {
            "node": "Upload photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set config (sensitive data)": {
      "main": [
        [
          {
            "node": "Authentication",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get photo (for testing purposes)": {
      "main": [
        [
          {
            "node": "Set destination",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Set config (sensitive data)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 工程, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类2
节点类型4
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Greg Evseev

Greg Evseev

@greg

15+ years in AI/ML development & integration. Now specializing in establishing ISO 42001-compliant AI management systems. Background includes AI/ML research, system development, AI governance, and ISO 42001 Lead Auditor training (in progress). Helping organizations: ✓ Evaluate AI maturity & governance ✓ Implement ISO 42001 systems ✓ Bridge technical & regulatory requirements ✓ Design practical AI governance frameworks Expertise: AI Risk Assessment, Compliance Strategy, Technical Due Diligence.

外部链接
在 n8n.io 查看

分享此工作流