Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 813
Panu Tangchalermkul Avatar asked Nov 07 '22 01:11

Panu Tangchalermkul


2 Answers

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

like image 74
vijay chemburkar Avatar answered Dec 27 '22 04:12

vijay chemburkar


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}

like image 37
Alex Prachuablarb Avatar answered Dec 27 '22 03:12

Alex Prachuablarb