3

Use Case

As an authorized LinkedIn user
I want to post articles via the LinkedIn API
So my external services can create content on behalf of me

Description

I want to post (not share) an article on LinkedIn via the LinkedIn API v2.

So far, I have succeeded with sharing text, images, and article-URLs. However, creating an article (Publishing Article), I don't fully understand how to do this.

There is the Article API, but that API has only methods for retrieving published articles. In the documentation, the UGC Post API is referenced as the publishing mechanism.

In the documentation of the UGC Post API, I can only find documentation for sharing text, images, and article-URLs. I'm missing out completely on the article creation.

The manual way for posting such articles on the LinkedIn-website is to go to LinkedIn Publishing at https://www.linkedin.com/post/new and create the content via a visual editor.

Publishing is however not available for all users. If it's available for one user is a decision - probably automated - made by LinkedIn. This is stated in the documentation here.

Publishing isn’t currently available to all members and access to publishing isn’t determined or affected by your account type. Both free and premium accounts can have publishing access. Having a premium account doesn’t guarantee publishing access.

Questions

  • Is it even possible to post an article with the LinkedIn API v2?
  • How can I post an article via the LinkedIn API v2?
  • Are there any additional permissions needed other than the ones specified for the UGC Post API (w_member_social)?

Existing Failing Requests

// request
{
    method: 'POST',
    headers: {
        Authorization: `Bearer ${accessToken}`,
        'X-Restli-Protocol-Version': '2.0.0'
    },
    uri: `${LINKEDIN_API_URL}/v2/ugcPosts`,
    json: true,
    body: {
        author: `urn:li:person:${linkedinUserId}`,
        lifecycleState: 'PUBLISHED',
        specificContent: {
            'com.linkedin.ugc.ShareContent': {
                shareCommentary: {
                    text: `<strong>Let's hope this is possible</strong><br/>it would be bad if not<br/>said by me at ${new Date()}`
                },
                shareMediaCategory: 'URN_REFERENCE'
            }
        },
        visibility: {
            'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC'
        }
    }
}

// response
{
    statusCode: 500,
    body: {
        message: 'INTERNAL SERVER ERROR',
        status: 500
    }
}
  • 1
    Publishing Articles are not available via the LinkedIn API at this time. – Christopher Ou May 06 '19 at 21:43
  • 1
    So basically you can read and delete Publishing Articles, but you can't create them. How does that make sense for an API development roadmap? Anyways, LinkedIn has got its own idea of how to properly confuse developers (Publishing Articles, posting videos via UGC Post API, mixture of depreciated and current permissions, ...) – Florian Schaeffler May 07 '19 at 10:29
  • 1
    @FlorianSchaeffler For its size, LinkedIn has absolutely the worst developer support I have experienced in the industry. Consider yourself incredibly lucky that Christopher Ou responded to your question! (Seriously) – rinogo Jun 26 '19 at 16:38

2 Answers2

0

Documentation is here!

The payload should be is like as this:

{"content": {
    "contentEntities": [
        {
            "entityLocation": "https://www.example.com/content.html",
            "thumbnails": [
                {
                    "resolvedUrl": "https://www.example.com/image.jpg"
                }
            ]
        }
    ],
    "title": "Test Share with Content"
},
"distribution": {
    "linkedInDistributionTarget": {}
},
"owner": "urn:li:person:324_kGGaLE",
"subject": "Test Share Subject",
"text": {
    "text": "Test Share!"
}}
lucas teles
  • 680
  • 9
  • 8
-4
// request
{
    method: 'POST',
    headers: {
        Authorization: `Bearer ${accessToken}`,
        'X-Restli-Protocol-Version': '2.0.0'
    },
    uri: `${LINKEDIN_API_URL}/v2/ugcPosts`,
    json: true,
    body: {
        author: `urn:li:person:${linkedinUserId}`,
        lifecycleState: 'PUBLISHED',
        specificContent: {
            'com.linkedin.ugc.ShareContent': {
                shareCommentary: {
                    text: `<strong>Let's hope this is possible</strong><br/>it would be bad if not<br/>said by me at ${new Date()}`
                },
                shareMediaCategory: 'NONE'
            }
        },
        visibility: {
            'com.linkedin.ugc.MemberNetworkVisibility': 'PUBLIC'
        }
    }
}
pzaenger
  • 11,381
  • 3
  • 45
  • 46