The secrets are printing fine, but I just can't get the format right.
def search_domains_on_godaddy(domains):
GODADDY_KEY = os.getenv('GODADDY_KEY')
GODADDY_SECRET = os.getenv('GODADDY_SECRET')
print("GODADDY_KEY", GODADDY_KEY)
print("GODADDY_SECRET", GODADDY_SECRET)
headers = {
'Authorization': f'sso-key {GODADDY_KEY}:{GODADDY_SECRET}',
'Content-Type': 'application/json',
}
# Prepare the payload
payload = {"domains": domains, "checkType": "FAST"}
print("payload", payload)
# Send POST request to check domain availability
response = requests.post('https://api.ote-godaddy.com/v1/domains/available', json=payload, headers=headers)
print("Response Status Code: ", response.status_code)
print("Response Headers: ", response.headers)
print("Response from godaddy: ", response.json())
if 'domains' in response.json():
available_domains = [item['domain'] for item in response.json()['domains'] if item['available']]
else:
available_domains = []
return available_domains
The response I'm getting:
payload {'domains': ['BootBazaar.com', 'StridePride.com', 'StompShop.com', 'FootlooseBoots.com', 'KickKiosk.com', 'TrekTrend.com', 'HeelHaven.com'], 'checkType': 'FAST'}
Response Status Code: 400
Response Headers: {'Content-Type': 'application/json', 'Content-Length': '72', 'Vary': 'origin', 'X-Request-Id': 'rFD9xX3Yj5jjaJqi6Ae13v', 'X-DataCenter': 'US_WEST_2', 'Expires': 'Fri, 25 Aug 2023 20:35:23 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Fri, 25 Aug 2023 20:35:23 GMT', 'Connection': 'close', 'Set-Cookie': '_abck=FA584D58EDE2768489DAFF6752811C91~-1~YAAQjDlAF2Fy5fWJAQAAcqFoLgooMKkDdcO6yCgjGHHbyZdJmaZxA39/vnI80ubzap3i/K0ZirPYGhUA7IKUjuGsJA0z9aWirL/73dcnqGObrupNJg+91cF8eaVbdDh9aDzGQ0/dxvoQxjjAr14u9Hkz6brOqwaGfhgDdXctg2sRFY3P/UJSAWdPlb6OT28fRnxP8HiNLBH4zIdXTG6XqHZOgrbK7h9QBBAQm2S2WcxfkmHCngBlDFwNuSsxpvRzvKcK37pMidX8FPtAqeSlcVHxKtEc3l4DM97yhQbR0JKN/2YZHTuGHCR977+I7/SvZVoqegS1GVaS7fvYyq8mtBIyj6HxBTcF9VGKN+rlA2qzvLBmUcol0DQU3dP25g==~-1~-1~-1; Domain=.ote-godaddy.com; Path=/; Expires=Sat, 24 Aug 2024 20:35:23 GMT; Max-Age=31536000; Secure, bm_sz=29A4DF4ABD11D16BBD4C90AA366EFCC6~YAAQjDlAF2Jy5fWJAQAAc6FoLhTcFq6oxYSZJ+GGlZSJz4Q+L4Obdq7Kpj0IKEICad4hkESCPKZDE6/rP992rhFqje5S1IS4XYV9aKsE9Qdgq5kUbktESw1LAUlya6BlFILlx1MJ8GUxuFWQd42YosDGI+vYfHU5oV0hso2KSYEMhQuojpkeGtklgEDtywCrVswDBJUz/6KNsnyZKq2PAfnhCWQlDmcdV+yGhoGEO0+M4BeHi7ptsMXpEJXP+Z6VFncdCsZaf3xgKmknJG6IKiPaf3li+2mgYqIZw496J+PnIHtMDA/T9g==~3354928~3686708; Domain=.ote-godaddy.com; Path=/; Expires=Sat, 26 Aug 2023 00:35:22 GMT; Max-Age=14399'}
**Response from godaddy: {'code': 'INVALID_BODY', 'message': "Request body doesn't fulfill schema"}**
The API docs I've been referencing: https://developer.godaddy.com/doc/endpoint/domains#/v1/availableBulk
As per the docs, checkType
is a query parameter, also the body should just be an array instead of an object.
So your requests.post
call should be:
response = requests.post('https://api.ote-godaddy.com/v1/domains/available', params={"checkType": "FAST"}, json=domains, headers=headers)
or alternatively:
response = requests.post('https://api.ote-godaddy.com/v1/domains/available?checkType=FAST', json=domains, headers=headers)