[英]Get request works in postman but not with python code - error 404
The request below is working in Postman but if I copy the code from Postman to VS Code
or PyCharm
I get always HTTP Error 404. The requested resource is not found. The request below is working in Postman but if I copy the code from Postman to
VS Code
or PyCharm
I get always HTTP Error 404. The requested resource is not found. I am running out of ideas, any help is appreciated.我的想法不多了,感谢您的帮助。 I am working behind a proxy but that is well sorted as far as I can see, since I had before the 407 error , which is solved now.
我在代理后面工作,但据我所知,这是很好的排序,因为我在407 错误之前有过,现在已经解决了。 The localhost
api
is a django api
I developed and I get it running from PyCharm
.本地主机
api
是django api
我开发的,我从PyCharm
运行它
import requests导入请求
url = "http://127.0.0.1:8000/api/jobs/"
payload={}
files={}
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers, data=payload, files=files)
print(response.text)
import os
import requests
os.environ['HTTP_PROXY'] = os.environ['http_proxy'] = 'http://http-connect-proxy:3128/'
os.environ['HTTPS_PROXY'] = os.environ['https_proxy'] = 'http://http-connect-proxy:3128/'
os.environ['NO_PROXY'] = os.environ['no_proxy'] = ''
url = "http://127.0.0.1:8000/api/jobs/"
payload={}
files={}
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers, data=payload, files=files)
print(response.text)
Could you try replacing it with your proxy server and try您可以尝试用您的代理服务器替换它并尝试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.