Retrieve UGC Posts through LinkedIn V2 API got ClassCastException error

北城余情 提交于 2019-12-07 05:40:50

问题


I'm trying to retrieve a list of UGC posts by calling the following API

https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List%28urn%3Ali%3Aorganization%3A[ORG_ID]%29

[ORG_ID] is id of my organization. Then I got this error

{
    "serviceErrorCode": 0,
    "message": "java.lang.ClassCastException: java.lang.String cannot be cast to com.linkedin.data.DataComplex",
    "status": 500
}

I've already authorized to use API V2 and include X-Restli-Protocol-Version:2.0.0 in the header.


回答1:


I was having issues with this too, the parens on the authors query param shouldn't be encoded.

I.e., try: https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A[ORG_ID])




回答2:


I tested it with the URL mentioned https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A[ORGANISATION ID]) and it works but make sure you set the header. X-Restli-Protocol-Version: 2.0.0

I had to do this manually however since postman apparently doesn't work and perhaps other http tools are having similar issues. https://github.com/postmanlabs/postman-app-support/issues/5752

The error returned by postman is the following or if you forget to include the header above: {"serviceErrorCode":0,"message":"java.lang.ClassCastException","status":500}



来源:https://stackoverflow.com/questions/52697531/retrieve-ugc-posts-through-linkedin-v2-api-got-classcastexception-error

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