LinkedIn API returns empty shares / posts and for adAnalyticsV2 nothing and empty for shares

Viewed 286

for my request:

 https://api.linkedin.com/v2/adAnalyticsV2?q=analytics&dateRange=(start:(day:1,month:9,year:2020),end:(day:1,month:9,year:2021))&timeGranularity=DAILY&pivot=SHARE&fields=externalWebsiteConversions,dateRange,impressions,landingPageClicks,likes,shares,costInLocalCurrency,pivot,pivotValue&companies=List(urn%3Ali%3Aorganization%3A<ORGANIZATION_ID>)

I get always empty return. What could it be? I do have all the required Permissions:

r_1st_connections_size, r_ads_reporting, r_basicprofile, r_emailaddress, r_liteprofile, r_organization_social, rw_ads, rw_organization_admin, w_member_social, w_organization_social

My goal is to get metrics as likes, impression for all my / organizations posts. I appreaciate any input, thanks a lot.

As return I get:

{
    "paging": {
        "start": 0,
        "count": 10,
        "links": []
    },
    "elements": []
}

Where for my shares:

https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:company:<MY_ORGANIZATION_ID>

I get an empty paging but with the right total count:

{
    "paging": {
        "start": 0,
        "count": 10,
        "links": [
            {
                "type": "application/json",
                "rel": "next",
                "href": "/v2/shares?count=10&owners=urn%3Ali%3Acompany%3A<MY_ORGANIZATION_ID>&q=owners&start=0"
            }
        ],
        "total": 569
    },
    "elements": []
}

Of course I use the generated bearer token for the request for which I have the listed permissions when I check in the https://www.linkedin.com/developers/tools/oauth/token-inspector.

I'm looking forward to any input and help. Thanks a lot.

2 Answers

Its because you may not have the admin access on the company page, you'll likely need to obtain a proper API key and secret to interact with the page via the Linkedin API.

I think there is a problem with the API and how it filters the data. I ran into the same issue and just kept trying.

I came to the conclusion that you have to ignore that the documentation tells you that you reached the end of the data if there are less results in the response than you requested. Also ignore the pagination info given in the request.

In your example you use the defaults for sharesPerOwner and count. You may want to include at least sharesPerOwner, because that defaults to 1. I worked with count=5 and sharesPerOwner=3000 (that's the max value allowed).

And for me I got 3 results when try with count=5&start=0. It tells me to get the next page with count=5&start=3, but when I try that, then I get no results. Next I tried count=5&start=5. No result there, either. But: My next attempt with count=5&start=10 returned a record. Just one, but more than none - and I kept increasing start by count over and over again. That worked until my start reached 3000 (sharesPerOwner?). I didn't get 3000 records, but ~1600.

So what I think is happening is that the API gathers records in a temp table. Something like this:

Records start=0 start=3 start=5 start=10
Record 1 <
Record 2 <
Record 3 <
null < <
null < <
null < <
null < <
null < <
null <
null <
Record 5 <
null <
null <
null <
null <

But that table has "dead" records and is too stupid to deal with them.

TLDR; My conclusion: Keep increasing start step by step (and work with a bigger count) until you have all the data you need. Don't let it confuse you with what seems to be the end of the data.

Related