LinkedIn: How do I retrieve statistics for specifi

2019-08-21 10:10发布

问题:

LinkedIn's API V2 docs specifically addresses this scenario on their Organization Share Statistics page, but I keep getting an error when trying a request based on their sample.

LinkedIn's sample request:

GET https://api.linkedin.com/v2/organizationalEntityShareStatistics
        ?q=organizationalEntity
        &organizationalEntity=urn:li:organization:2414183
        &shares[0]=urn:li:share:1000000
        &shares[1]=urn:li:share:1000001

My request (from a REST client):

GET https://api.linkedin.com/v2/organizationalEntityShareStatistics
        ?q=organizationalEntity
        &organizationalEntity=urn%3Ali%3Aorganization%3A(my org id)
        &shares[0]=urn%3Ali%3Ashare%3A(my share id)

The response:

{
    "serviceErrorCode": 100,
    "message": "Unpermitted fields present in PARAMETER: Data Processing Exception while processing fields [/shares[0]]",
    "status": 403
}

I have also tried URL-encoding the square brackets (same error) and dropping the [0] from the param (error "Invalid value type for parameter shares"). Does anyone know the proper way to format this request?

回答1:

Got it: the proper format is

GET https://api.linkedin.com/v2/organizationalEntityShareStatistics
        ?q=organizationalEntity
        &organizationalEntity=urn%3Ali%3Aorganization%3A(my org id)
        &shares=List(urn%3Ali%3Ashare%3A(my share id))