LinkedIn 营销 API 中的报告端点

问题描述 投票:0回答:1

我一直在尝试使用新的“版本化”LinkedIn Marketing API 来尝试对我的活动进行任何类型的分析。利用 python 和请求。在here.

中找到文档
import requests

headers = {
   'X-Restli-Protocol-Version': '2.0.0',
   'Authorization': 'Bearer {TOKEN}',
   'Linkedin-Version': '202303',
}

url = 'https://api.linkedin.com/rest/adAnalytics?q=statistics&pivot=CAMPAIGN&dateRange.start.day=1&dateRange.start.month=3&dateRange.start.year=2023&timeGranularity=DAILY&fields=pivotValue&accounts=urn%3Ali%3AsponsoredAccount%3A507920541'

response = requests.get(url, headers=headers)
print(response)

经过一系列的战斗,我已经确定我最近的努力产生了这个结果:

{'errorDetailType': 'com.linkedin.common.error.BadRequest', '消息': '查询参数验证期间发生多个错误。请参见 errorDetails 获取更多信息。', 'errorDetails': {'inputErrors': [{'input': {'inputPath': {'fieldPath': 'dateRange.start.day'}}, '代码':'QUERY_PARAM_NOT_ALLOWED'},{'输入':{'inputPath': {'fieldPath': 'dateRange.start.month'}}, 'code': 'QUERY_PARAM_NOT_ALLOWED'},{'输入':{'inputPath':{'fieldPath': 'dateRange.start.year'}}, 'code': 'QUERY_PARAM_NOT_ALLOWED'}]}, '状态':400}

我不知道它在寻找日期范围。如果将 Linkedin-Version 更改为 202302,我会收到此错误:

{'status': 403, 'serviceErrorCode': 100, 'code': 'ACCESS_DENIED', '消息':'参数中存在不允许的字段:数据处理 处理字段时出现异常 [/dateRange.start.day, /dateRange.start.month, /dateRange.start.year]'}

非常感谢您的建议。

编辑

按照评论中的建议使用邮递员产生了这个:

{ “状态”:400, “代码”:“ILLEGAL_ARGUMENT”, “消息”:“传递给请求的查询参数无效” }

这是网址,我认为它被设置为旧版本 tbh.

https://api.linkedin.com/rest/adAnalytics?q=statistics&dateRange.start.year=2023&dateRange.start.month=3&dateRange.start.day=1&dateRange.end.year=2023&dateRange.end.month=03&dateRange。 end.day=20&timeGranularity=ALL&accounts=urn:li:sponsoredAccount:507920541&pivots[0]=CAMPAIGN&pivots[1]=CONVERSION&fields=externalWebsiteConversions,externalWebsitePostClickConversions,externalWebsitePostViewConversions,costInLocalCurrency,externalWebsiteConversions,costInLocalCurrency,dateRange,pivotValues

python linkedin linkedin-api
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.