Parameter 'targetingCriteria' is invalid for audience count with LinkedIn marketing API

≯℡__Kan透↙ 提交于 2021-01-28 12:59:32

问题


I was trying to get audience count by using targetingCriteriaV2 by Curl and Guzzle request but its showing as targetingCriteria is invalid.

API url 1:

https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3Ana))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))

API url 2:

https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3AjobFunctionsList(urn%3Ali%3Afunction%3A1,urn%3Ali%3Afunction%3A8,urn%3Ali%3Afunction%3A5))))))


回答1:


You should pass the X-Restli-Protocol-Version: 2.0.0 as the header in your API requests, as example:

curl \
   -H "Authorization:Bearer <the-token>" \
   -H "Content-Type:application/json" \
   -H "X-Restli-Protocol-Version: 2.0.0" \
   "https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3Ana))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))"

There are also two other problems with your api calls:

The first API use a legacy geo locations: urn:li:countryGroup:na you should use BING geo locations. As example for North America you should use urn:li:geo:102221843 and the API call will success like:

curl \
   -H "Authorization:Bearer <the token>" \
   -H "Content-Type:application/json" \
   -H "X-Restli-Protocol-Version: 2.0.0" \
   "https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3Ageo%3A102221843))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))"

{"paging":{"start":0,"count":10,"links":[]},"elements":[{"active":0,"total":2900000}]}%

The second API call seems malformed, yes a very strange format for targeting locations !!!!



来源:https://stackoverflow.com/questions/65255274/parameter-targetingcriteria-is-invalid-for-audience-count-with-linkedin-market

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!