在获得请求时获得请求错误422

时间:2020-04-03 11:47:41

标签: python python-requests

我已经看到了一些与此相关的帖子,但是其中大多数使用了request.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)

我尝试使用https://api.autobuy.io/?version=latest的api的文档

编辑:在其网站上显示

HEADERS
APIKey
2cdbdc48-b297-41ad-a234-329db0d2dbea

AutoBuy Api Key found in your shop settings

但是当我删除Cache-ControlPragma标头时,我得到一个错误,该错误与标头被缓存有关(因为站点位于CDN后面了?)

1 个答案:

答案 0 :(得分:-1)

最终是站点中的错误,我的仪表板显示了无效的密钥。