python - 获取请求时获取请求错误 422
问题描述
我看过一些关于此的帖子,但其中大多数都使用 requests.post 并且我想要一个获取请求。
我正在制作一个程序,它只是转到一个 url 并获取一个订单列表。
这是示例响应:
{
"page": 1,
"pageCount": 22,
"orderCount": 214,
"orders": [
{
"id": "c1497823-370c-4c7a-82cd-dacddb36fc30",
"productId": "1a641ba5-38df-4acb-86f7-f5c031e538a0",
"email": "demoemail@autobuy.io",
"ipAddress": "127.0.0.1",
"total": 18,
"currency": "USD",
"gateway": "Stripe",
"isComplete": true,
"createdAtUtc": "2019-10-15T01:44:10.5446599+00:00"
},
{
"id": "228f4ca4-5001-4c19-8350-f960f13d35a7",
"productId": "a0041cc0-2bc6-40a2-9084-5880bae5ecec",
"email": "demoemail@autobuy.io",
"ipAddress": "127.0.0.1",
"total": 50,
"currency": "USD",
"gateway": "Stripe",
"isComplete": true,
"createdAtUtc": "2019-10-15T01:43:17.8322919+00:00"
},
{
"id": "71aed9b2-4bd2-4a49-9e6a-82119e6e05bf",
"productId": "2e0ac75b-bfea-42f1-ad60-ead17825162a",
"email": "demoemail@autobuy.io",
"ipAddress": "127.0.0.1",
"total": 6,
"currency": "USD",
"gateway": "Stripe",
"isComplete": true,
"createdAtUtc": "2019-10-14T23:54:44.6217478+00:00"
}
]
}
这就是我得到的:
<Response [422]>
我的代码:
import requests
url = "https://autobuy.io/api/Orders?page=1"
headers = {
"Cache-Control": "no-cache",
"Pragma": "no-cache",
"APIKey": "<APIKEY>"
}
req = requests.get(url, headers=headers)
print(req)
我正在尝试使用的 api 文档https://api.autobuy.io/?version=latest
编辑:在他们的网站上说
HEADERS
APIKey
2cdbdc48-b297-41ad-a234-329db0d2dbea
AutoBuy Api Key found in your shop settings
但是当我删除我的Cache-Control
和Pragma
标头时,我收到一个与我的标头被缓存有关的错误(因为该站点位于 CDN 后面?)
解决方案
最终成为网站中的错误,我的仪表板显示无效密钥。
推荐阅读
- c++ - 预期的容器行为
- python - ValueError:无法覆盖主键字段
- java - 如何仅解析 JSONArray 的特定部分?
- amazon-web-services - 从 GCP 项目连接到 AWS VPC 中的实例
- spring-boot - 允许 spring boot 以失败的健康检查开始
- javascript - 反应类名未在 switch 语句中定义
- php - 在 Php 中以一种语法将多组命名元素添加到数组
- c# - matchtemplate openCv2 python不匹配类似的样子
- outlook - 自动订阅 iCalendar (RFC5545) 提要
- xml - RSS 提要导入所有 youtube 频道视频