Access to workflow via api appears 401 #12351

Closed
opened 2026-02-21 19:07:02 -05:00 by yindo · 1 comment
Owner

Originally created by @dgzxx-2000 on GitHub (Mar 30, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

import requests

def upload_raw_binary(binary_data, file_name,file_type):

    upload_url = "https://api.dify.ai/v1/files/upload"
    
    headers = {
        'Authorization': f'Bearer app-xxxxx'
    }

    proxies = {
        'http': 'http://127.0.0.1:33210',  # HTTP 代理
        'https': 'http://127.0.0.1:33210'  # HTTPS 代理
    }
    
   
    response = requests.post(
        upload_url,
        proxies=proxies,
        headers=headers,
        files={'file': (file_name, binary_data, 'application/octet-stream')},
        data={"user": "abc-123", "type": file_type}
    )
    print(response)
    
    return response.json().get("id")

audio_id = upload_raw_binary(audio_binary_data, r"D:\hf_pro\Image_recognition\Ultraman\audio\1.m4a", file_type="audio")
image_id = upload_raw_binary(image_binary_data, r"D:\hf_pro\Image_recognition\Ultraman\images\1.png", file_type="image")
ConnectionResetError                      Traceback (most recent call last)
File d:\anconda\Lib\site-packages\urllib3\connectionpool.py:775, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
    [774](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:774) try:
--> [775](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:775)     self._prepare_proxy(conn)
    [776](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:776) except (BaseSSLError, OSError, SocketTimeout) as e:

File d:\anconda\Lib\site-packages\urllib3\connectionpool.py:1044, in HTTPSConnectionPool._prepare_proxy(self, conn)
   [1038](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1038) conn.set_tunnel(
   [1039](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1039)     scheme=tunnel_scheme,
   [1040](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1040)     host=self._tunnel_host,
   [1041](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1041)     port=self.port,
   [1042](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1042)     headers=self.proxy_headers,
   [1043](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1043) )
-> [1044](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1044) conn.connect()

File d:\anconda\Lib\site-packages\urllib3\connection.py:730, in HTTPSConnection.connect(self)
    [728](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:728) server_hostname_rm_dot = server_hostname.rstrip(".")
--> [730](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:730) sock_and_verified = _ssl_wrap_socket_and_match_hostname(
    [731](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:731)     sock=sock,
    [732](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:732)     cert_reqs=self.cert_reqs,
    [733](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:733)     ssl_version=self.ssl_version,
    [734](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:734)     ssl_minimum_version=self.ssl_minimum_version,
    [735](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:735)     ssl_maximum_version=self.ssl_maximum_version,
    [736](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:736)     ca_certs=self.ca_certs,
...
    [684](file:///D:/anconda/Lib/site-packages/requests/adapters.py:684) except MaxRetryError as e:
    [685](file:///D:/anconda/Lib/site-packages/requests/adapters.py:685)     if isinstance(e.reason, ConnectTimeoutError):
    [686](file:///D:/anconda/Lib/site-packages/requests/adapters.py:686)         # TODO: Remove this in 3.0.0: see #2811

ConnectionError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?6812b0f7-c3e9-40a2-b7da-ef448566bdeb) or open in a [text editor](command:workbench.action.openLargeOutput?6812b0f7-c3e9-40a2-b7da-ef448566bdeb). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @dgzxx-2000 on GitHub (Mar 30, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ``` import requests def upload_raw_binary(binary_data, file_name,file_type): upload_url = "https://api.dify.ai/v1/files/upload" headers = { 'Authorization': f'Bearer app-xxxxx' } proxies = { 'http': 'http://127.0.0.1:33210', # HTTP 代理 'https': 'http://127.0.0.1:33210' # HTTPS 代理 } response = requests.post( upload_url, proxies=proxies, headers=headers, files={'file': (file_name, binary_data, 'application/octet-stream')}, data={"user": "abc-123", "type": file_type} ) print(response) return response.json().get("id") audio_id = upload_raw_binary(audio_binary_data, r"D:\hf_pro\Image_recognition\Ultraman\audio\1.m4a", file_type="audio") image_id = upload_raw_binary(image_binary_data, r"D:\hf_pro\Image_recognition\Ultraman\images\1.png", file_type="image") ``` ``` ConnectionResetError Traceback (most recent call last) File d:\anconda\Lib\site-packages\urllib3\connectionpool.py:775, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw) [774](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:774) try: --> [775](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:775) self._prepare_proxy(conn) [776](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:776) except (BaseSSLError, OSError, SocketTimeout) as e: File d:\anconda\Lib\site-packages\urllib3\connectionpool.py:1044, in HTTPSConnectionPool._prepare_proxy(self, conn) [1038](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1038) conn.set_tunnel( [1039](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1039) scheme=tunnel_scheme, [1040](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1040) host=self._tunnel_host, [1041](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1041) port=self.port, [1042](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1042) headers=self.proxy_headers, [1043](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1043) ) -> [1044](file:///D:/anconda/Lib/site-packages/urllib3/connectionpool.py:1044) conn.connect() File d:\anconda\Lib\site-packages\urllib3\connection.py:730, in HTTPSConnection.connect(self) [728](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:728) server_hostname_rm_dot = server_hostname.rstrip(".") --> [730](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:730) sock_and_verified = _ssl_wrap_socket_and_match_hostname( [731](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:731) sock=sock, [732](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:732) cert_reqs=self.cert_reqs, [733](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:733) ssl_version=self.ssl_version, [734](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:734) ssl_minimum_version=self.ssl_minimum_version, [735](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:735) ssl_maximum_version=self.ssl_maximum_version, [736](file:///D:/anconda/Lib/site-packages/urllib3/connection.py:736) ca_certs=self.ca_certs, ... [684](file:///D:/anconda/Lib/site-packages/requests/adapters.py:684) except MaxRetryError as e: [685](file:///D:/anconda/Lib/site-packages/requests/adapters.py:685) if isinstance(e.reason, ConnectTimeoutError): [686](file:///D:/anconda/Lib/site-packages/requests/adapters.py:686) # TODO: Remove this in 3.0.0: see #2811 ConnectionError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)) Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?6812b0f7-c3e9-40a2-b7da-ef448566bdeb) or open in a [text editor](command:workbench.action.openLargeOutput?6812b0f7-c3e9-40a2-b7da-ef448566bdeb). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)... ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🤔 cant-reproduce label 2026-02-21 19:07:02 -05:00
yindo closed this issue 2026-02-21 19:07:02 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 30, 2025):

Hello @dgzxx-2000! 👋 I'm here to help you with bug fixes, questions, and becoming a contributor. Let's squash those bugs together!

The 401 error you're encountering when accessing the workflow API might be due to an incorrectly formatted Authorization token. Ensure that the token is included in the Authorization header using the format 'Bearer '. Verify that the API key is valid and matches the one provided by Dify [1].

Regarding the ConnectionResetError, this can occur due to incorrect proxy configuration or the proxy being unavailable. Ensure that your proxy settings are correct and that the proxy server is accessible. Avoid using localhost addresses (like 127.0.0.1) for proxy settings in a Docker environment, as they may not be reachable from within the container. Instead, use the host machine's address [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 30, 2025): <!-- Greeting --> Hello @dgzxx-2000! 👋 I'm here to help you with bug fixes, questions, and becoming a contributor. Let's squash those bugs together! <!-- Answer --> The 401 error you're encountering when accessing the workflow API might be due to an incorrectly formatted Authorization token. Ensure that the token is included in the Authorization header using the format 'Bearer <api-key>'. Verify that the API key is valid and matches the one provided by Dify <sup>[[1]](https://github.com/langgenius/dify-docs/issues/412)</sup>. Regarding the `ConnectionResetError`, this can occur due to incorrect proxy configuration or the proxy being unavailable. Ensure that your proxy settings are correct and that the proxy server is accessible. Avoid using localhost addresses (like 127.0.0.1) for proxy settings in a Docker environment, as they may not be reachable from within the container. Instead, use the host machine's address <sup>[[2]](https://github.com/langgenius/dify/issues/11739)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0db32e3a-6550-4ca4-bd5c-d9c4d90dd42f?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12351