There is a Similar Question
I tried the solution which was given in the answer.
I tried multiple scenarios, but I keep getting the below error:
URL1:
var companyid = '123456789';
var url = "https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List("+ encodeURIComponent(companyid)+")";
Log of the url
returns below url:
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A123456789)
URL2:
var companyid = '123456789';
var url = "https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List("+(companyid)+")";
Log of the url
returns below url:
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn:li:organization:123456789)
Here are the permissions I have requested for authentication:
r_liteprofile
r_emailaddress
w_member_social
rw_organization_admin
rw_organization
r_organization_social
You should add the header information about the V2 protocol version ad described in the doc:
All API requests are represented in protocol 2.0.0 and require the header X-Restli-Protocol-Version: 2.0.0.
So if you made the API Call Like:
curl -H "X-Restli-Protocol-Version:2.0.0" "https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A123456789)&oauth2_access_token=<access_token>"
You will retrieve some data, like:
{"elements":[],"paging":{"total":0,"count":10,"start":0,"links":[]}
Hope this help