Publish on LinkedIn company page - linkedin

So I'm trying to publish a post on a company page using the ugcPosts API.
When I'm doing in to a personal account it works great but when I'm doing it for a company page I get status "201 Created" but it doesnt appear on the company page.
I'm using the test company page https://www.linkedin.com/company/devtestco/
The user I'm authenticated with has permissions:
- r_liteprofile
- r_emailaddress
- w_member_social
- w_organization_social
- r_organization_social
I make the call to:
https://api.linkedin.com/v2/ugcPosts
with the body
{
"author": "urn:li:organization:2414183",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "A share comment"
},
"shareMediaCategory": "ARTICLE",
"media": [
{
"status": "READY",
"description": {
"text": "A description"
},
"originalUrl": "https://linkedin.com/",
"title": {
"text": "A title"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
Am I doing something wrong? Is there any problems with https://www.linkedin.com/company/devtestco/ test company page? Is there another company page used for testing?
Like I said, I recieve "Created" response but where is it then? The devtestco page doesnt have any posts at all which I find weird since I cant be the only one using it.

So I tested with a "real" company page instead and it worked, so there seems to be something weird with the page https://www.linkedin.com/company/devtestco/

Related

The LinkedIn Assets API don't show my upload in the linkedin newfeed

I'm using LinkedIn API to upload media to my Linkedin personal profile. I start with registring my image and I get a successful response.
REQUEST
{
"registerUploadRequest":{
"owner":"urn:li:person:xxx",
"recipes":[
"urn:li:digitalmediaRecipe:feedshare-image"
],
"serviceRelationships":[
{
"identifier":"urn:li:userGeneratedContent",
"relationshipType":"OWNER"
}
],
"supportedUploadMechanism":[
"SYNCHRONOUS_UPLOAD"
]
}
}
RESPONSE
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {
"media-type-family": "STILLIMAGE"
},
"uploadUrl": "xxxx"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:xxx,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:xxx"
}
}
Next step I uploaded my image using curl with a valid access token and the uploadUrl
I get a 201 HTTP response but I see nothing in my LinkedIn profile.
also when I check the status of my upload it shows me a success message.
{"recipes":[{"recipe":"urn:li:digitalmediaRecipe:feedshare-image","status":"AVAILABLE"}],"serviceRelationships":[{"relationshipType":"OWNER","identifier":"urn:li:userGeneratedContent"}],"mediaTypeFamily":"STILLIMAGE","created":1606729082880,"id":"C4D22AQE6h5xe3HYYiQ","lastModified":1606729322981,"status":"ALLOWED"}
So why I can't see my upload in the Linkedin timeline, please? I tried with both image and video but nothing is shown in my newsfeed.
Also, I checked my access token and it contains necessary permission: r_liteprofile, w_member_social
Uploading an asset does not make it available on your profile.
Assets API only uploads the image/video and stores it on LinkedIn platform. You can however use this asset to create a UGC Post to see it on your personal/company profile.
To do that, you'll have to use the ugcPosts API. ie call POST https://api.linkedin.com/v2/ugcPosts with
"media": "urn:li:digitalmediaAsset:XXX", from the Assets API response in the payload.
Example:
{
"author": "urn:li:organization:5590506",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"media": "urn:li:digitalmediaAsset:XXX", // from the Assets API response
"status": "READY",
"title": {
"attributes": [],
"text": "Sample Video Create"
}
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"targetAudience": {
"targetedEntities": [
{
"locations": [
"urn:li:country:us",
"urn:li:country:gb"
],
"seniorities": [
"urn:li:seniority:3"
]
}
]
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
Reference: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api#sample-request

LinkedIn creative ad with an image and a call-to-action

Using LinkedIn APIs I'm trying to create a Creative Ad with an image and a call-to-action button like the following example from campaignmanager:
I tried many possibilities using Asset and Share APIs to create a dark Share but i'm unable to create a Creative with an image and a call-to-action button. The example in the documentation doesn't say if I should use ARTICLE or RICH shareMediaCategory. Setting landingPageUrl like in this example seems to have no effect when using from a Creative Ad.
I successfully created a video Creative Ad with a call-to-action but the new UgcPost API is only supporting AdDirectSponsoredContent for video.
Does somebody know how to do it?
Thank you
I found a workaround by creating first a RICH dark share that accepts an uploaded asset urn in the entity field:
POST https://api.linkedin.com/v2/shares
{
"owner": "urn:li:organization:1234",
"agent": "urn:li:sponsoredAccount:5678",
"subject": "An ad title",
"text": {
"text": "An ad title"
},
"content": {
"contentEntities": [
{
"entity": "urn:li:digitalmediaAsset:ABCD",
"entityLocation": "https://stackoverflow.com"
}
],
"shareMediaCategory": "RICH"
},
"distribution": {
"linkedInDistributionTarget": {}
}
}
Then I create a 2nd ARTICLE dark share with the thumbnails info recovered from the 1st dark share plus the "call to action" button:
POST https://api.linkedin.com/v2/shares
{
"owner": "urn:li:organization:1234",
"agent": "urn:li:sponsoredAccount:5678",
"subject": "An ad title",
"text": {
"text": "An ad title"
},
"content": {
"contentEntities": [
{
"entityLocation": "https://stackoverflow.com",
"thumbnails": [
{
"resolvedUrl": "https://media-exp1.licdn.com/dms/image/ABCD/feedshare-shrink_1280/..."
}
],
"title": "Click here to learn more!",
"landingPageUrl": "https://stackoverflow.com",
"landingPageTitle": "LEARN_MORE"
}
],
"shareMediaCategory": "ARTICLE"
},
"distribution": {
"linkedInDistributionTarget": {}
}
}

Custom image in a linked post not working through API for LinkedIn profile

linkedin
Hi,
When we replace preview of a URL with a custom image, recently we have seen that they have stopped getting posted with the custom image on LinkedIn profiles through API. It works on LinkedIn companies.
Is it a temporary bug or some change of which we were not informed?
An example given below.
Thanks.
{
"author": "urn:li:person:9DeFJQSxT0",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "hello amit recurpost.com test"
},
"shareMediaCategory": "ARTICLE",
"media": [
{
"status": "READY",
"description": {
"text": "Kickstart your social media marketing and manage multiple social accounts from a single dashboard with one powerful and affordable social media scheduling tool."
},
"originalUrl": "https://recurpost.page.link/awqx",
"thumbnails": [
{
"url": "https://rpdevelopers.blob.core.windows.net/imagesdev/1589179465_5eb8f44941d96.jpeg"
}
],
"title": {
"text": "Social Media Scheduler with Repeating Schedules | RecurPost"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}

Bad request: Attempting to associate a ugc with an asset that's not owned by the author

I'm trying to migrate my app from LinkedIn API v1 to v2. I'm currently looking at sharing images (natively) to my personal LinkedIn profile.
I'm following the official docs here: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share
To register the image I made the following POST request: to https://api.linkedin.com/v2/assets?action=registerUpload
{
"registerUploadRequest": {
"recipes": [
"urn:li:digitalmediaRecipe:feedshare-image"
],
"owner": "urn:li:person:9PyfTxBTFY",
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
]
}
}
I got the success response:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {},
"uploadUrl": "https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw"
}
}
I successfully uploaded an image as binary using the returned uploadUrl:
curl -i --upload-file PATH_TO_FILE --header "Authorization: Bearer TOKEN" 'https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1'
To confirm that the image is ready for use, I checked the status of the asset with the GET https://api.linkedin.com/v2/assets/C4D22AQEGOHxBzKUXvw which returned
{
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
],
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1547564914979,
"lastModified": 1547564994321,
"id": "C4D22AQEGOHxBzKUXvw",
"status": "ALLOWED"
}
Based on the docs, I can now simply reference the asset URN in the UGC post.
This is the test image post I'm trying to share using the https://api.linkedin.com/v2/ugcPosts endpoint
{
"author": "urn:li:person:9PyfTxBTFY",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Testing LinkedIn image shares"
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": "Some text"
},
"media": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw",
"title": {
"text": "Some title"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
But I keep getting the error:
{
"message": "Attempting to associate a ugc with an asset that's not owned by the author",
"status": 400
}
The above request works perfectly when trying to share a status update or a link attachment.
I haven't tried it with videos yet (similar approach) since I assume I will face the same problem. I haven't tried sharing as an organization either since I need to be accepted to the LinkedIn Marketing Developer Program first.
I can confirm that this has been fixed by the LinkedIn Developer Team. Follow the same steps as above and it should work perfectly, as long as the authenticated user has granted the w_member_social permission.
On the last request I now get 201 Created response with the header X-RestLi-Id containing the link to the new post urn:li:share:6494126499975700480.
https://www.linkedin.com/feed/update/urn:li:share:6494126499975700480
P.S. If you're re-trying an old request / registered upload, it won't work, so make sure you try it with a new asset. I believe the bug was when registering uploads.

permission error while making ugc video post on linkedin

I am trying to create video post on linkedin with new ugc endpoint
there are two steps to create this type of post
1). Upload video asset on linkedin server (done)
2). make post request to ugc endpoint with request body
I have successfully uploaded the video but getting authentication error for ugc post request. error is
{
"message": "urn:li:developerApplication:<id1> does not have permission to create ugc posts with author: li:member:<id2>",
"status": 401
}
I am passing the request body as suggested in the linkedin api docs.
{
"author": "urn:li:person:<id>",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"title": {
"attributes": [],
"text": "Sample Video Create"
},
"description": {
"attributes": [],
"text": "Sample Description"
},
"media": "urn:li:digitalmediaAsset:<asset_id>",
"thumbnails": [],
"status": "READY"
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
},
"targetAudience": {
"targetedEntities": [
{
"locations": [
"urn:li:country:us"
]
}
]
}
}
Please suggest how I can solve this problem. From error message it seems like I am not providing some permission. But I am not sure where I am making mistake.
This is the response I got from the LinkedIn Developer Support:
"Hi Ervin,
Creating video UGC posts is currently a whitelisted feature. There is currently hold on whitelisting new apps for video.
You may continue to create UGC posts that are not video though.
I'll put this on hold until I have more information on when we can whitelist apps again.
Best,
Alex"

Resources