[问题] 同个网址,只能GET,无法POST

楼主: Federer5566 (费德勒5566)   2023-08-28 11:46:50
大家好
最近遇到一个问题
一个有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:
作者: DaOppaiLoli (大欧派萝莉)   2023-08-29 18:30:00
Server 处理这个 Request 会需要花很久的时间吗
作者: Woqeker (窝颗ker)   2023-08-30 00:05:00
试试加个 header Content-Type: text/plain
作者: virgil246 (virgil585)   2023-08-30 14:18:00
我会用ngrok之类的工具把两种语言打出来的request 拿出来看哪里不一样
作者: papple23g (逆道者)   2023-08-31 01:59:00
postman能成功POST的话 可以看它转的python怎么写
作者: gostjoke (鬼笑话)   2023-09-02 04:01:00
先用postman看看吧 也有可能被挡了 试试看改表头
作者: gomi (勾亿郎)   2023-09-04 11:47:00
没有 auth 吗?毕竟 post
作者: s860134 (s860134)   2023-09-10 04:36:00
通灵: server 有检查 headers,你里面有关键字被挡掉requests: 'User-Agent': 'python-requests/2.31.0'
作者: hidos (hidos)   2023-10-28 11:06:00
data那边用json.dumps转一下再丢出去

Links booklink

Contact Us: admin [ a t ] ucptt.com