I am migrating from using https://api.linkedin.com/v2/ugcPosts to https://api.linkedin.com/rest/posts.
The UgcPosts API call to create a post in the organization works:
POST https://api.linkedin.com/v2/ugcPosts
Header: X-Restli-Protocol-Version: 2.0.0
{
"author": "urn:li:organization:73873366",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Share commentary text."
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": "Description text."
},
"media": "urn:li:digitalmediaAsset:D4D22AQHZkwZQ-pS_AQ",
"title": {
"text": "Title text."
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
The response is 201 Created giving me { "id": "urn:li:share:7069267959319339009" }.
However if I use the new posts API it complains (I am following the official documentation Single Post Creation Sample Request:
POST https://api.linkedin.com/rest/posts
Header: X-Restli-Protocol-Version: 2.0.0
Header: LinkedIn-Version: 202305
{
"author": "urn:li:organization:73873366",
"commentary": "My cool image.",
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "MAIN_FEED",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"content": {
"media": {
"title":"Name of the image",
"id": "urn:li:image:D4D22AQHZkwZQ-pS_AQ"
}
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}
The response I get is 400 Bad Request:
{
"message": "Organization permissions must be used when using organization as author",
"status": 400
}
By reading the documentation I could not figure out what are the steps needed. I tried getting information with the /rest/organizationAuthorizations endpoint as described in LinkedIn Documentation Organization Authorizations but it gives me problems.
I am trying get-organization-authorization-information as described in the documentation follows:
GET https://api.linkedin.com/rest/organizationAuthorizations/(impersonator:urn%3Ali%3Aperson%3ASnbx29l-ix,organization:urn%3Ali%3Aorganization%3A73873366,action:(organizationRoleAuthorizationAction:(actionType:ADMINISTRATOR_READ)))
Header: X-Restli-Protocol-Version: 2.0.0
Header: LinkedIn-Version: 202305
Which yields a 400 Bad Request:
{
"status": 400,
"code": "ILLEGAL_ARGUMENT",
"message": "Syntax exception in path variables"
}
I believe there's a problem in the documentation.
These are the permissions with the token I am playing with:
POST https://www.linkedin.com/oauth/v2/introspectToken
Header: X-Restli-Protocol-Version: 2.0.0
{ "token": "...", "client_id": "...", "secret": "..."}
Response:
{
"active": true,
"client_id": "...",
"authorized_at": 1685445569,
"created_at": 1685445569,
"status": "active",
"expires_at": 1690629570,
"scope": "r_emailaddress,r_liteprofile,r_member_live,r_organization_admin,r_organization_live,w_member_live,w_member_social,w_organization_live",
"auth_type": "3L"
}
My concerts summarized:
Organization permissions must be used when using organization as author mean? Do I need to pass a separate token? The user I am playing with has admin access to the organization I'm using. Should I perhaps tweak the Organization permissions with the LinkedIn UI?/v2/ -> /rest/ migration. Will it be sunset?Theoretically, if you included in your OAuth2 scopes w_organization_social you should be able to create posts with the new APIs just like you did with the unversioned ones, meaning without any new permission.
That said, I had a similar problem where on my own account, using new tokens with all scopes enabled, the rest/posts endpoint kept erroring.
This is probably because the only /v2 APIs that are going to sunset on June 30in favor of the /rest (versioned) ones are the Marketing APIs.
If you post, you're using the Share on LinkedIn APIs which don't seem fully functional in their /rest form. This also means that you don't need to transition to the new APIs.
Anyways, one possible workaround that I haven't tested yet could be to add every organization scope (rw_organization_admin, r_organization_social, w_organization_social, r_organization_admin).
I think what could be going on is that you can't create a post if you don't have the r_organization_admin permission as well. Still, this is just a hypothesis.
I'll message their support on ZenDesk to see if they have a better answer.
TL;DR: No, the consumer unversioned APIs will not sunset anytime soon. I encountered a similar problem on a personal profile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With