LinkedIn API: Creating UGC Image Post for Organization 500 response - linkedin

I'm attempting to post images to organization linkedin pages. I'm working off of this documentation: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api
So far I have the following working:
shareMediaCategory type "ARTICLE" shared to a person
shareMediaCategory type "ARTICLE" shared to an organization
shareMediaCategory type "IMAGE" shared to a person
When I attempt to post with shareMediaCategory type "IMAGE" to an organization, I get the following error response:
{
"message": "Internal Server Error",
"status": 500
}
Here is the url:
https://api.linkedin.com/v2/ugcPosts
The Headers (I have tried with and without all these headers):
Authorization:Bearer REDACTED
Content-Type:application/json
X-Restli-Protocol-Version:2.0.0
x-li-format:json
And the body:
{
"author":"urn:li:organization:2414183",
"lifecycleState":"PUBLISHED",
"specificContent":{
"com.linkedin.ugc.ShareContent":{
"shareCommentary":{
"text":"Hello"
},
"shareMediaCategory":"IMAGE",
"media":[
{
"status": "READY",
"description":{
"text":"Here is the description"
},
"media":"urn:li:digitalmediaAsset:C4E22AQFdCtnVOTxQCQ",
"title":{
"text":"This is the title"
}
}
]
}
},
"visibility":{
"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"
}
}
The organization id is a LinkedIn test org ID: https://developer.linkedin.com/docs/guide/v2/organizations/development-testing
I can post articles to that ID, but images 500.
I've tested that the image has been uploaded successfully.

Related

Linked In API article thumbnails

I'm trying to migrate existing code that fetches organization posts from ugcPosts API to new versioned call of the Posts API(version 202210) and I'm facing issues with getting thumbnails for articles. Response that I get from Posts API doesn't contain thumbnail URL but instead it contains thumbnail URN(old ugcPost API returned thumbnail URL as a part of the post). Here is an example of an article post that I get from API
{
"isReshareDisabledByAuthor": false,
"createdAt": 1666603988797,
"lifecycleState": "PUBLISHED",
"lastModifiedAt": 1666603988797,
"visibility": "PUBLIC",
"publishedAt": 1666603988797,
"author": "urn:li:organization:1111",
"id": "urn:li:share:2222",
"distribution": {
"feedDistribution": "MAIN_FEED",
"thirdPartyDistributionChannels": []
},
"content": {
"article": {
"description": "some description",
"thumbnail": "urn:li:image:3333",
"source": "https://example.com",
"title": "some title"
}
},
"commentary": "some comment",
"lifecycleStateInfo": {
"isEditedByAuthor": false
}
}
I tried to use Images API to fetch thumbnail URL using a call
GET https://api.linkedin.com/rest/images/urn:li:image:3333
Unfortunately Linked In API responds with code 400 and message Invalid asset owner urn type provided: urn:li:article:4444
I don't get why it happens. Token that I'm using has enough permissions to fetch organization posts(token's scope contains permissions w_member_social, r_liteprofile, r_1st_connections_size, w_organization_social, r_member_social, r_organization_social, rw_organization_admin). Article id that presents in error message isn't anyhow connected to post id. It's also not clear why that asset is referenced as urn:li:article while the post itself is described as urn:li:share. To me it looks like Linked In API bug or am I doing something wrong?
Turns out there was a bug in Linked In API which was confirmed by their support. At this moment same calls work fine with version 202210

Can't create category via WP REST API

I am attempting to create categories via the WordPress REST API but getting the following error:
{
"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create terms in this taxonomy.",
"data": {
"status": 401
}
}
The REST API user I'm using is an administrator. I've confirmed that I'm authenticating correctly because I can create pages via the REST API.
Here is the JSON I'm submitting to https://hostname.net/wp-json/wp/v2/categories
{
"description":"",
"name": "Test",
"slug": "test",
"parent": 51,
"meta": []
}
I've confirmed that the category with id 51 exists (created that via the UI). The content-type header is set to application/json.
What is the correct syntax to create a new category via the WP REST API?

Getting a 400 Error when doing a simple text post

Trying to migrate our calls away from the v2/ugcPosts endpoint to the new /rest/posts endpoint. I started off trying to create a text-only post as per the Text-Only Post Creation Sample Request
I copied and pasted the request body, changed the organization ID to my own, and included Authorization: Bearer {My Authorization Token}, X-Restli-Protocol-Version: 2.0.0, Content-Type: application/json, LinkedIn-Version:202207 as headers.
POST https://api.linkedin.com/rest/posts
{
"author": "urn:li:organization:***",
"commentary": "Sample text Post",
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "NONE",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}
However, when trying to post, I keep getting this 400 error.
{
"errorDetailType": "com.linkedin.common.error.BadRequest",
"code": "MISSING_REQUIRED_FIELD_FOR_DSC",
"message": "Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request",
"errorDetails": {
"inputErrors": [
{
"description": "Field /adContext/dscAdAccount is required when the post is a Direct Sponsored Content, but missing in the request",
"input": {
"inputPath": {
"fieldPath": "/adContext/dscAdAccount"
}
},
"code": "MISSING_REQUIRED_FIELD_FOR_DSC"
}
]
},
"status": 400
}
I see that lifecycleState, distribution, visibility, commentary, author are all required, but adContext should be an optional field. I'm not sure what part of my request is indicating I'm trying to make a Direct Sponsored Content post - can someone take a look?
I've already tried
Removing the targetEntities and thirdPartyDistributionChannels parameters.
Removing isReshareDisabledByAuthor and the above.
Changing the feedDistribution to MAIN_FEED and NONE
Creating the post via the /v2/ugcPosts endpoint - meaning the authorization token and organization urn are correct

Facebook Graph API Error 200 after requesting comments for a facebook page post

When I try to get all the comments below a facebook page post using the graph api explorer via
GET
https://graph.facebook.com/12.0/{post-id}?fields=comments
the answer looks like:
{
"error": {
"message": "(#200) Missing Permissions",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "AqyOUwmTl...3n5y-Br"
}
}
Why?
In case I just request the post like
GET
https://graph.facebook.com/12.0/{post-id}
I got back a valid answer:
{
"created_time": "2021-12-21T10:05:40+0000",
"message": "This is a test post.",
"id": "x0xxxxxxxxxx95_1xxxxxxxxx74"
}
This is kinda strange because I request these datas with an admin user of the facebook page and set the following permissions for the access token:
read_insights
pages_show_list
instagram_basic
publish_to_groups
pages_read_engagement
pages_read_user_content
pages_manage_posts
public_profile
Appreciate any help, thank you.
Instead of use "User token" you have to use "Page token"

Commenting on a LinkedIn post using REST API returning 500

I have a linkedin company page.I am trying to post a comment on an already existed post of that page via Linkedin Rest API.
Below are the request details :
HTTP METHOD : POST
URL : https://api.linkedin.com/v2/socialActions/urn:li:activity:{activity-id}/comments
HEADERS : Authorization, Content-Type
BODY :
{"actor": "urn:li:organizationBrand:<org id>",
"message": {
"attributes": [],
"text": "This is a comment"
}}
The above request is throwing me the below error :
{"message": "com.linkedin.restli.client.RestLiResponseException: Response status 500, serviceErrorMessage: Error creating comment",
"status": 500}
The same request works for me for another linkedin company page. Can you please help me on finding what the issue is?

Resources