[Python] LinkedIn API: Consistent 500 Internal Server Errors When Retrieving Organizational...

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I am encountering Internal Server Error (HTTP status code 500) when attempting to retrieve organizational entity statistics and followers using the LinkedIn API. The organization URN is 12668855. Below are the details of the issue:

    Endpoints:

    1. https://api.linkedin.com/rest/organ...ntity&organizationalEntity={organization_URN}
    2. https://api.linkedin.com/rest/organ...ntity&organizationalEntity={organization_URN}

    Error Response:

    { "message": "Internal Server Error", "status": 500 }

    Expected Outcome: I expect to receive valid statistical and follwers data for the specified organizational entity

    Additional Information: I have already contacted LinkedIn support, and they suggested posting this issue on Stack Overflow for further assistance.

    Python code I am using :

    import os

    import requests

    from dotenv import load_dotenv

    load_dotenv()

    ACCESS_TOKEN = os.getenv('ACCESS_TOKEN')

    ORGANIZATION_ID = os.getenv('ORGANIZATION_ID')

    headers = {
    'Authorization': f'Bearer {ACCESS_TOKEN}',
    'LinkedIn-Version': '202405',
    'X-Restli-Protocol-Version':'2.0.0'
    }

    url_1 = f'https://api.linkedin.com/rest/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity={ORGANIZATION_ID}'

    url_2 =f"https://api.linkedin.com/rest/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity={ORGANIZATION_ID}"

    shares_response = requests.get(url=url_1, headers=headers)

    shares_data = shares_response.json()

    print(shares_data)

    followers_response = requests.get(url=url_2,headers=headers)

    follwers_data = followers_response.json()

    print(follwers_data)


    **Output I am getting :**

    {'message': 'Internal Server Error', 'status': 500}

    {'message': 'Internal Server Error', 'status': 500}


    Expected Outcome :

    Expected to receive valid statistical data and followers data for the specified organizational entity


    Document referred for APIs:

    https://learn.microsoft.com/en-us/l...ower-statistics?view=li-lms-2024-05&tabs=http

    Continue reading...

Compartilhe esta Página