Post 请求来自邮递员的作品,而不是来自 python
Post request works from postman but not from python
当我 运行 来自邮递员的这个脚本成功发布到 gettr 时,但是当我 运行 它在 pycharm 中与脚本邮递员给我时它给了我错误。
{"_t":"xresp","rc":"ERR","error":{"_t":"xerr","code":"E_RES_NOACCESS","emsg":"empty post","args":[]}}"
这与我 运行 邮递员中的代码但没有正文表单数据时得到的错误代码相同,无论我做什么我似乎都无法修复它,我已经尝试重命名有效载荷,更改一行中的最大字符数,因为我认为这可能是问题所在,并且 json 对有效载荷进行编码。
有效负载未发送到服务器,其他所有内容都已发送,但有效负载未发送,我不明白为什么。
这是邮递员给我的代码
import requests
url = "https://api.gettr.com/u/post"
payload={'content': '{"data":{"udate":1627766410444,"acl":{"_t":"acl"},"_t":"post","cdate":1627766410444,"txt":"TEST2","uid":"nseruame2"},"aux":null,"serial":"post"}'}
files=[
]
headers = {
'authority': 'api.gettr.com',
'x-app-url': 'https://gettr.com',
'enctype': 'multipart/form-data',
'x-app-auth': '{"user":"nseruame2","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJuc2VydWFtZTIiLCJsZXZlbCI6MCwiaWF0IjoxNjI3NzY1NTU3LCJleHAiOjE2MzI5NDk1NTd9.x5WfCL2ts9ZPRPfrXoRsx8Ht9_Qwvu8a6Z0LsST2c-Q"}',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Safari/537.36',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundarylT5AFlKSBTmaMSRX',
'sec-gpc': '1',
'origin': 'https://gettr.com',
'sec-fetch-site': 'same-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'referer': 'https://gettr.com/',
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
我做错了什么导致了这个错误,我该如何解决。
E_RES_NOACCESS 表示未为其提供身份验证令牌,服务器未获取有效负载,因为错误代码表明它丢失了存储在有效负载中的所有关键内容。
这不是一个答案,但问题是请求模块无法发送内容配置来分离有效载荷,因此服务器正在接收有效载荷但没有正确解释它,我发现我可以在 node.js 所以我就这么做
当我 运行 来自邮递员的这个脚本成功发布到 gettr 时,但是当我 运行 它在 pycharm 中与脚本邮递员给我时它给了我错误。
{"_t":"xresp","rc":"ERR","error":{"_t":"xerr","code":"E_RES_NOACCESS","emsg":"empty post","args":[]}}"
这与我 运行 邮递员中的代码但没有正文表单数据时得到的错误代码相同,无论我做什么我似乎都无法修复它,我已经尝试重命名有效载荷,更改一行中的最大字符数,因为我认为这可能是问题所在,并且 json 对有效载荷进行编码。 有效负载未发送到服务器,其他所有内容都已发送,但有效负载未发送,我不明白为什么。
这是邮递员给我的代码
import requests
url = "https://api.gettr.com/u/post"
payload={'content': '{"data":{"udate":1627766410444,"acl":{"_t":"acl"},"_t":"post","cdate":1627766410444,"txt":"TEST2","uid":"nseruame2"},"aux":null,"serial":"post"}'}
files=[
]
headers = {
'authority': 'api.gettr.com',
'x-app-url': 'https://gettr.com',
'enctype': 'multipart/form-data',
'x-app-auth': '{"user":"nseruame2","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJuc2VydWFtZTIiLCJsZXZlbCI6MCwiaWF0IjoxNjI3NzY1NTU3LCJleHAiOjE2MzI5NDk1NTd9.x5WfCL2ts9ZPRPfrXoRsx8Ht9_Qwvu8a6Z0LsST2c-Q"}',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Safari/537.36',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundarylT5AFlKSBTmaMSRX',
'sec-gpc': '1',
'origin': 'https://gettr.com',
'sec-fetch-site': 'same-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'referer': 'https://gettr.com/',
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
我做错了什么导致了这个错误,我该如何解决。
E_RES_NOACCESS 表示未为其提供身份验证令牌,服务器未获取有效负载,因为错误代码表明它丢失了存储在有效负载中的所有关键内容。
这不是一个答案,但问题是请求模块无法发送内容配置来分离有效载荷,因此服务器正在接收有效载荷但没有正确解释它,我发现我可以在 node.js 所以我就这么做