[問題] 同個網址,只能GET,無法POST

看板Python作者 (費德勒5566)時間8月前 (2023/08/28 11:46), 編輯推噓2(203)
留言5則, 4人參與, 8月前最新討論串1/1
大家好 最近遇到一個問題 一個有GET和POST的應用程式網址 用requests寫 跑GET沒問題,但跑POST會失敗 有試過用其他語言寫,GET和POST都OK 所以應該可以排除網路環境issue 不曉得該如何解決... 程式碼如下面三行(網址隱碼): import requests my_data = {'msg': 'TEST'} r = requests.post('***.***.**/***.********',data = my_data) 跑到timeout之後顯示的訊息如下(網址隱碼): HTTPSConnectionPool(host='***.***.**', port=443): Max retries exceeded with url:***.******** (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000021D6C3466D0>: Failed to establish a new connection: [WinError 10060] 連 線嘗試失敗,因為連線對象有一段時間並未正確回應,或是連線建立失敗,因為連線的主 機無法回應。')) During handling of the above exception, another exception occurred: During handling of the above exception, another exception occurred: During handling of the above exception, another exception occurred: -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.71.216.244 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1693194412.A.B78.html

08/29 18:30, 8月前 , 1F
Server 處理這個 Request 會需要花很久的時間嗎
08/29 18:30, 1F

08/30 00:05, 8月前 , 2F
試試加個 header Content-Type: text/plain
08/30 00:05, 2F

08/30 14:18, 8月前 , 3F
我會用ngrok之類的工具
08/30 14:18, 3F

08/30 14:18, 8月前 , 4F
把兩種語言打出來的request 拿出來看哪裡不一樣
08/30 14:18, 4F

08/31 01:59, 8月前 , 5F
postman能成功POST的話 可以看它轉的python怎麼寫
08/31 01:59, 5F
文章代碼(AID): #1ax1Yiju (Python)
文章代碼(AID): #1ax1Yiju (Python)