能够使用POSTMAN而不是PYTHON访问端点

能够使用POSTMAN而不是PYTHON访问端点,python,post,postman,google-colaboratory,Python,Post,Postman,Google Colaboratory,我有一个POST端点,如下所示: http://localhost:8080/*****/***********/orders/k137982151 import requests url = "http://localhost:8080/*****/***********/orders/k137982151" headers = { 'content-type': "application/x-www-form-urlencoded", 'cache-control':

我有一个POST端点,如下所示:

http://localhost:8080/*****/***********/orders/k137982151
import requests

url = "http://localhost:8080/*****/***********/orders/k137982151"

headers = {
    'content-type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache",
    'postman-token': "********-*****-***-****-********"
    }

response = requests.request("POST", url, headers=headers)

print(response.status_code)
我在《邮差》上得到了成功的回复

我使用POSTMAN生成了一个python代码片段,如下所示:

http://localhost:8080/*****/***********/orders/k137982151
import requests

url = "http://localhost:8080/*****/***********/orders/k137982151"

headers = {
    'content-type': "application/x-www-form-urlencoded",
    'cache-control': "no-cache",
    'postman-token': "********-*****-***-****-********"
    }

response = requests.request("POST", url, headers=headers)

print(response.status_code)

结果我得到了404。我也尝试过使用urllib。我还是拿到了404。我遗漏了什么?

如果你使用
请求,你还会得到404吗。post(url,headers=headers)
?是的。它仍然返回404。顺便说一句,我正在使用谷歌协作实验室。你认为这可能会造成问题吗?你有没有试过从邮递员那里发帖。很可能,它工作得很好。您的端点是自托管的(请参见
localhost
),我相信邮递员请求来自您的本地计算机。据我对Google Colaboratory的了解,他们的笔记本电脑托管在某个地方的Google服务器上,该服务器无法访问您的
localhost
。我怀疑如果您将代码保存到一个文件并在本地运行,它可能会工作。