Python-API戈达迪问题(响应[422])
你好 我试图创建一个对Godaddy的API的请求,但得到一个错误Python-API戈达迪问题(响应[422]),python,json,api,python-requests,godaddy-api,Python,Json,Api,Python Requests,Godaddy Api,你好 我试图创建一个对Godaddy的API的请求,但得到一个错误 {"code":"INVALID_BODY","message":"Request body doesn't fulfill schema, see details in `fields`"} <Response [422]> import requests import json from datetime import datet
{"code":"INVALID_BODY","message":"Request body doesn't fulfill schema, see details in `fields`"}
<Response [422]>
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()