Search code examples
linkedin-api

Retrieve UGC Posts through LinkedIn V2 API got ClassCastException error


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.


Solution

  • 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])