I’m trying to fetch company posts from LinkedIn using the ugcPosts API. The response shows total: 449, but elements is an empty array.
- Access Token Retrieved Successfully
I’m able to authenticate and get an access token. Example token (truncated for security):
AQVDf5VKdYJGIBL9... (token works for other endpoints too)
- API Endpoint Called
$accessToken = '...'; // valid token
$organizationId = 'urn:li:organization:organizationid';
$encodedOrgId = urlencode($organizationId);
$url = "https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List($encodedOrgId)";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $accessToken",
"X-Restli-Protocol-Version: 2.0.0"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
Issues:
-
API shows
total: 449posts. -
But
elementsarray is always empty. -
Tried pagination, still empty.
Token has the scopes:
-
r_organization_social -
rw_organization_admin
Things I’ve Checked:
-
Access token is valid.
-
Organization URN is correct.
-
User is a Super Admin of the organization.
-
Token has proper scopes.
-
Other API calls like
/v2/organizations/{id}work fine. -
Using latest
X-Restli-Protocol-Version: 2.0.0.
-
Why does
ugcPostsshow a total count but no elements? -
Is there any additional permission needed?
-
Is this behavior expected for posts created by other admins or scheduling tools?
-
How can I debug or verify ownership of the posts?