首页 > 解决方案 > Python - API Godaddy 问题(响应 [422])

问题描述

再会!

我正在尝试创建对 Godaddy 的 API 的请求并收到错误。

{"code":"INVALID_BODY","message":"Request body doesn't fulfill schema, see details in `fields`"}

<Response [422]>

我试过了:

  1. 更改日期时间格式
  2. 更改电话格式
  3. 更改名称服务器列表
  4. 将 nameServer 行留空
  5. 更改标题
  6. 免费域名
  7. 更改传真线路(“”、“”、“+380.931002784”、“+380.931002783”)不起作用。

这已经持续了超过 2 周,因为 godaddy 支持会在 70 小时内响应。

我将不胜感激。

API Godaddy https://developer.godaddy.com/doc/endpoint/domains#/v1/purchase

我的代码

import requests
import json
from datetime import datetime



def buy_domain():

    api_key = "my key"
    secret_key = "my key"
    headers = {"Authorization": "sso-key {}:{}".format(api_key, secret_key), 'Accept': 'application/json'}


    x=datetime.utcnow().isoformat()[:-3]+'Z'
    print(x)
    doma =json.dumps(
    {
        "consent": {
          "agreedAt": "2021-04-27T22:56:01.31Z",
          "agreedBy": "7.2.19.158",
          "agreementKeys": ["DNRA"]
        },
        "contactAdmin": {
          "addressMailing": {
            "address1": "1 May 520/2",
            "address2": "1 May 520/1",
            "city": "Haysyn",
            "country": "UA",
            "postalCode": "23700",
            "state": "Vinnytsia Oblast"
        },
          "email": "s.zor@gmail.com",
          "fax": " ",
          "jobTitle": "Owner",
          "nameFirst": "Artem",
          "nameLast": "Ivanov",
          "nameMiddle": "Vitalevich",
          "organization": "SE s",
          "phone": "+380.931002784"
        },
        "contactBilling": {
          "addressMailing": {
            "address1": "1 May 520/2",
            "address2": "1 May 520/1",
            "city": "Haysyn",
            "country": "UA",
            "postalCode": "23700",
            "state": "Vinnytsia Oblast"
          },
          "email": "s.zor@gmail.com",
          "fax": " ",
          "jobTitle": "Owner",
          "nameFirst": "Artem",
          "nameLast": "Ivanov",
          "nameMiddle": "Vitalevich",
          "organization": "SEM Experts",
          "phone": "+380.931002784"
        },
        "contactRegistrant": {
          "addressMailing": {
            "address1": "1 May 520/2",
            "address2": "1 May 520/1",
            "city": "Haysyn",
            "country": "UA",
            "postalCode": "23700",
            "state": "Vinnytsia Oblast"
          },
          "email": "s.zor@gmail.com",
          "fax": " ",
          "jobTitle": "Owner",
          "nameFirst": "Artem",
          "nameLast": "Ivanov",
          "nameMiddle": "Vitalevich",
          "organization": "SE s",
          "phone": "+380.931002784"
        },
        "contactTech": {
          "addressMailing": {
            "address1": "1 May 520/2",
            "address2": "1 May 520/1",
            "city": "Haysyn",
            "country": "UA",
            "postalCode": "23700",
            "state": "Vinnytsia Oblast"
          },
          "email": "s.zor@gmail.com",
          "fax": " ",
          "jobTitle": "Owner",
          "nameFirst": "Artem",
          "nameLast": "Ivanov",
          "nameMiddle": "Vitalevich",
          "organization": "SE s",
          "phone": "+380.931002784"
        },
        "domain": "0000hwcp.com",
        "nameServers": ["dns15.pointhq.com", "dns12.pointhq.com", "dns8.pointhq.com"],
        "period": 1,
        "privacy": False,
        "renewAuto": True
    })

    print(doma, type(doma))
    # url = "https://api.godaddy.com/v1/domains/purchase"
    url='https://api.godaddy.com/v1/domains/purchase/validate'

    availability_res = requests.post(url, json=doma, headers=headers)
    print(headers)
    print(availability_res.status_code)
    print(availability_res.text)
    print(availability_res)



buy_domain()

标签: pythonjsonapipython-requestsgodaddy-api

解决方案


推荐阅读