linkedin-apilinkedin-jsapi

LinkedIn API V1 - Receiving “Unauthorized request” when posting to Companies/{companyId}/shares


We are receiving 403 responses when posting to the company shares endpoint.
This happens when using the example company 2414183 and our chosen company.

The call to is-company-share-enabled endpoint is successful.

We are checking that the user is authenticated before making the request.
The LinkedIn profile we are using is set up as an company admin.
The domains we are calling from have been added to the Valid SDK Domains list.

It looks like the app usage & limits is counting these failed requests.

We can successfully post from Postman to both companies shares with varying payloads (using Postmans in built OAuth 2.0).

Would anyone be able to help us with this?

Here are some of the failed request ids
58LETKI9LD
RBG4DRL5VT
XYCOX9XID1
JPY6AORIKW

The code being used is mostly from the developer guides.

<script type="text/javascript" src="//platform.linkedin.com/in.js">
    api_key: [removed]
    authorize: false
</script>

$scope.postToLinkedInCompanyPage = function () {
    if (!IN.User.isAuthorized()) {
        IN.User.authorize(shareLinkedInCompanyPageContent);
    }
    else {
        shareLinkedInCompanyPageContent();
   }
};

function shareLinkedInCompanyPageContent() {
    if (!IN.User.isAuthorized()) {
        console.error("User not authorized");
        return;
    }

    var payload = {
      "comment": "Check out developer.linkedin.com! http://linkd.in/1FC2PyG",
      "visibility": {
            "code": "anyone"
        }
    };

    var cpnyID = [removed];

    IN.API.Raw("/companies/" + cpnyID + "/shares?format=json")
    .method("POST")
    .body(JSON.stringify(payload))
    .result(onSuccess)
    .error(onError);
}
function onSuccess(data) {
    console.log(data);
}
function onError(error) {
    console.log(error);
}

06/12/2018 - Update I tried the code out into a simple web app. Converting the angular into plain JavaScript. When posting to the test company 2414183, I still receive 403

POST https://api.linkedin.com/v1/companies/2414183/shares?format=json 403  
{errorCode: 0, message: "Unauthorized request", requestId: "259UFIKLIR", status: 403, timestamp: 1544085898666}

Solution

  • Version 1 of the API is no longer supported.

    Here is an extract from the LinkedIn dev blog

    Update: As of May 1, 2019, Version 1.0 of our API is no longer supported. Applications requesting Version 1.0 APIs may experience issues as we begin to remove services. To find the latest updates, go to the new LinkedIn Developers site at https://www.linkedin.com/developers/. You can learn more about our Version 2.0 APIs, our developer program, and how to migrate your apps.

    I'll update the tags and header so this isn't picked up in future searches