You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用GoDaddy API出现"Request body doesn't fulfill schema"错误的原因排查

GoDaddy批量域名查询API请求格式错误排查

问题现象

密钥GODADDY_KEY和GODADDY_SECRET打印正常,但调用GoDaddy批量域名查询API时返回400错误,响应提示INVALID_BODY: Request body doesn't fulfill schema。

排查方向及解决方案

1. 域名格式不符合API要求

GoDaddy域名查询API要求域名必须为纯格式(不含http://、www.前缀),且API Schema通常强制要求小写格式(尽管域名本身大小写不敏感)。

  • 修复操作:标准化域名格式,转换为小写并去除多余空格:
    cleaned_domains = [domain.strip().lower() for domain in domains]
    

2. 可选字段checkType存在环境兼容性问题

API文档标注checkType为可选字段(支持FAST/FULL),但OTE测试环境可能对该字段有特殊限制。

  • 修复操作:暂时移除checkType字段,仅保留必填的domains数组测试:
    payload = {"domains": cleaned_domains}
    

3. 请求体序列化异常

虽然requests.post的json参数会自动序列化并设置Content-Type,极端场景下可能存在序列化偏差。

  • 修复操作:手动序列化请求体并指定data参数:
    payload = json.dumps({"domains": cleaned_domains})
    response = requests.post(
        'https://api.ote-godaddy.com/v1/domains/available',
        data=payload,
        headers=headers
    )
    

4. 字段拼写错误核对

再次确认请求体字段名与API文档完全一致:

  • 确保字段为domains(复数形式),而非domain
  • 确保checkType大小写正确(首字母大写)

修改后的示例代码

def search_domains_on_godaddy(domains):
    import os
    import requests
    import json

    GODADDY_KEY = os.getenv('GODADDY_KEY')
    GODADDY_SECRET = os.getenv('GODADDY_SECRET')
    print("GODADDY_KEY", GODADDY_KEY)
    print("GODADDY_SECRET", GODADDY_SECRET)
    
    # 清理并标准化域名格式
    cleaned_domains = [domain.strip().lower() for domain in domains]
    
    headers = {
        'Authorization': f'sso-key {GODADDY_KEY}:{GODADDY_SECRET}',
        'Content-Type': 'application/json',
    }

    # 简化请求体,仅保留必填字段
    payload = {"domains": cleaned_domains}
    
    print("payload", payload)
    
    response = requests.post(
        'https://api.ote-godaddy.com/v1/domains/available',
        json=payload,
        headers=headers
    )
    
    print("Response Status Code: ", response.status_code)
    print("Response from godaddy: ", response.json())
    
    available_domains = []
    if 'domains' in response.json():
        available_domains = [item['domain'] for item in response.json()['domains'] if item['available']]
    
    return available_domains

内容的提问来源于stack exchange,提问作者Norbert

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 14:00:41