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

使用SponsoredAccount URN调用LinkedIn API获销售线索报400错误求助

问题:通过SponsoredAccount URN调用LinkedIn API获取销售线索时遭遇400错误

调用LinkedIn API获取销售线索时,传入SponsoredAccount的URN后收到以下400错误:

{
    "errorDetailType": "com.linkedin.common.error.BadRequest",
    "message": "Multiple errors occurred during param validation. Please see errorDetails for more information.",
    "errorDetails": {
        "inputErrors": [
            {
                "description": "ERROR :: /value :: union type is not backed by a DataMap or null",
                "input": {
                    "inputPath": {
                        "fieldPath": "owner/value"
                    }
                },
                "code": "FIELD_INVALID"
            },
            {
                "description": "Invalid value for field; wrong type or other syntax error",
                "input": {
                    "inputPath": {
                        "fieldPath": "owner/value"
                    }
                },
                "code": "FIELD_INVALID"
            }
        ]
    },
    "status": 400
}

以下是测试过的代码(包含多种尝试写法的注释):

# encoded_owner = quote(urn, safe='')
# encoded_owner = quote(f'(sponsoredAccount:{urn})', safe='')

headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json',
    "LinkedIn-Version": "202402"
}

# leads_url = f"https://api.linkedin.com/rest/leadForms?owner=(sponsoredAccount:{encoded_owner})&q=owner"
leads_url = f"https://api.linkedin.com/rest/leadForms?owner=(sponsoredAccount:{urn})&q=owner"
# leads_url = f"https://api.linkedin.com/rest/leadForms?owner={encoded_owner}&q=owner"
# leads_url = f'https://api.linkedin.com/rest/leadForms?owner=(sponsoredAccount:urn%3Ali%sponsoredAccount%3A{sponsoredAccount_id})&q=owner&count=10&start=0'

response = requests.get(leads_url, headers=headers)

排查建议

  • 检查URN完整性:确保urn变量是完整的SponsoredAccount URN,格式为urn:li:sponsoredAccount:{账号ID},不能仅传入数字ID。
  • 避免多余编码:owner参数需使用未编码的结构化格式(sponsoredAccount:{完整URN}),不需要对整个结构或URN做URL编码。
  • 核对参数格式:直接硬编码正确格式的URN进行测试(如owner=(sponsoredAccount:urn:li:sponsoredAccount:123456)),排除变量替换错误。
  • 验证权限与版本:确认access_token拥有r_leadgen_automation或rw_ads权限,且LinkedIn-Version与文档要求的202402一致。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 12:42:43