问题
I have some problem with the "Find Entities by URNs" API in order to retrieve the metadata and value information for a collection of URNs.
If I use the URL described in the doc (Sample request) with a valid access token:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3AfieldOfStudy%3A100990,urn%3Ali%3Aorganization%3A1035,urn%3Ali%3Aseniority%3A9)&locale=(language:en,country:US)&oauth2_access_token=<a-valid-token>
I receive the message:
{
"serviceErrorCode": 0,
"message": "java.lang.ClassCastException",
"status": 500
}
Anyone have experience the same issue? Any idea how to fix it?
Also: how can i contact for technical support as in this case?
UPDATE:
I made some try and I fix using the following version:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=urn%3Ali%3AfieldOfStudy%3A100990&urns=urn%3Ali%3Aorganization%3A1035&urns=urn%3Ali%3Aseniority%3A9&locale.language=it&locale.country=IT&oauth2_access_token=<a-valid-token>
BUT the locale/language translation is not working. Could be this a working solutions?
回答1:
From the support team:
Our docs are missing 1 critical piece of information. Whenever using LIST and encoded URNs in the URL, we expect an additional header
'x-restli-protocol-version: 2.0.0'
The correct API call would be Request:
curl -X GET \ 'https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3Aindustry%3A1,urn%3Ali%3Aseniority%3A9)&locale=(language:it,country:IT)' \ -H 'x-restli-protocol-version: 2.0.0' \ -H 'Authorization: Bearer <Token>'
Response:
{ "elements": [ { "facetUrn": "urn:li:adTargetingFacet:industries", "name": "Difesa e spazio", "urn": "urn:li:industry:1" }, { "facetUrn": "urn:li:adTargetingFacet:seniorities", "name": "Partner", "urn": "urn:li:seniority:9" } ], "paging": { "count": 2147483647, "links": [], "start": 0 } }
Yes, it does provide a response in locale.
Hope this can help other guys in the future
来源:https://stackoverflow.com/questions/56222238/ad-targeting-find-entities-by-urns-api-classcastexception-error-message