Posting through linkedin v2 api shows corrupt characters - linkedin

I am trying to create a post with Linkedin V2 api.
POST https://api.linkedin.com/v2/posts
The post is posting fine. The issue is when characters from different languages are used. It shows corrupted (Attached in Pic)
The text that I am trying to post is: "Læs mere og støt på"
This is how I am creating an object to post.
const options = {
"author": urn,
"commentary": text,
"visibility": "PUBLIC",
"distribution": {
"feedDistribution": "MAIN_FEED",
"targetEntities": [],
"thirdPartyDistributionChannels": []
},
"content":{
"media":{
"title": "Test title",
"id": assetsUrn
}
},
"lifecycleState": "PUBLISHED",
"isReshareDisabledByAuthor": false
}
Is there any way to fix this issue? Tried some encoding stuff as well but all in vain. Any help would be highly appreciated.

I've contacted the linkedin developer team and it seems to be and issue at their end which is fixed now.

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

Fetch company posts from linkedin API

I am trying to fetch the posts of the company from the api, I have already applied to the marketing development platform and it was approved. I already got the token with the scope: r_organization_social and I'm calling the /shares api:
https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{company_ID}&sharesPerOwner=100&count=25&sharesPerOwner=10
But I'm getting the following response:
{
"paging": {
"start": 0,
"count": 25,
"links": [
{
"type": "application/json",
"rel": "next",
"href": "/v2/shares?count=25&owners=urn%3Ali%3Aorganization%3A{company_ID}&q=owners&sharesPerOwner=10&sharesPerOwner=100&start=0"
}
],
"total": 242
},
"elements": []
}
I tried to change the query params and it's still the same
This end-point worked for me:
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A<ID_ORGANIZATION>)
See documentation: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api?tabs=http#sample-request-6
Disclaimer: I've no access to the linkedin API and couldn't test. But these are some things I noticed:
Your url contains two times the paramater sharesPerOwner, try removing one.
In the docs it's recommended to set the sharesPerOwner to 1000 and the count to 50. I'd also include the start paramater, just to make sure:
Maybe try something like this:
GET https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:organization:{id}&sharesPerOwner=1000&count=50&start=0
From the api-docs(https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#find-shares-by-owner): "Note that the pagination excludes UGC and Direct Sponsored Content (DSC) posts". Make sure that the owner you are testing contains posts.
If this doesn't work. Could you provide some information on how you are sending the request? Have you tried accessing other parts of the api?

Linkedin API - UGCPost Video url is missing

I am using following endpoint to fetch posts
https://api.linkedin.com/v2/ugcPosts?q=authors&authors[0]=urn:li:organization:XXXX&count=100&start=0
"media": [{
"recipes": [
"urn:li:digitalmediaProcessedAsset:(urn:li:digitalmediaAsset:XXXXXXXXXX,urn:li:digitalmediaRecipe:feedshare-video-captions-thumbnails)"
],
"media": "urn:li:digitalmediaAsset:XXXXXXXXXX",
"thumbnails": [],
"status": "READY"
}]
I could see only digitalmedia Asset, But couldn't find original Url like sharable url like
https://dms.licdn.com/playback/C5105AQGCJKQiUe3pmw/8f26be64328644c090703fdc3afd05a8/feedshare-mp4_3300-captions-thumbnails/1507940147251-drlcss?e=1571133600&v=beta&t=RgRX9RM_Z50wt4cwqEHQ79vY6NU-KNcKVPFbEIftqAc
Note : For image, we are getting original Url
https://media.licdn.com/dms/image/C5122AQHvWYVXpP2Few/feedshare-shrink_1280/0?e=1573689600&v=beta&t=gLeLjTO5OlyF-F0RESk9YdSyqMggXLNmkWSUOqldFXw
Using projection helped to solve this issue
https://api.linkedin.com/v2/ugcPosts?q=authors&authors[0]=urn:li:organization:XXXXX&count=100&projection=(paging,elements*(name,localizedName,vanityName,created(actor~(localizedFirstName, localizedLastName)),lastModified(actor~(localizedFirstName, localizedLastName)),specificContent(com.linkedin.ugc.ShareContent(shareMediaCategory,shareCommentary,media(*(media~:playableStreams,originalUrl,description,title))))))
Projection parameter working as of Feb 2020
(paging,elements*(id,created,lastModified,author,specificContent(com.linkedin.ugc.ShareContent(shareMediaCategory,shareCommentary,media(*(media~:playableStreams,originalUrl,description,title))))))

What should the "author" field for a LinkedIn UGC post be for Showcase/Brand pages?

I am trying to specify an author for a UGC post to a showcase page. I am expecting that the author of the showcase post is the showcase page itself, which is what happens when I manually create a post, but this doesn't seem to work with the API.
Let's say I have a showcase urn:li:organizationBrand:123456. If I specify the showcase as the author ("author": "urn:li:organizationBrand:123456) I get an error about an invalid "author" field. But if I wrap the brand URN ID with "organization" instead of "organizationBrand" ("author": "urn:li:organization:123456") it works but I have not found this interchangeability documented anywhere.
This same workaround works for retrieving post stats (/organizationalEntityShareStatistics).
Can anyone explain what the right approach is supposed to be?
Are organization brand URNs meant to effectively be an alias of organization URNs?
You can use the organizationalEntityAcls API to find your URN. organization URNs are not necessarily interchangeable with organizationBrand URNs.
For example:
GET https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee
"paging": {
"count": 10,
"start": 0
},
"elements": [
{
"state": "APPROVED",
"role": "ADMINISTRATOR",
"roleAssignee": "urn:li:person:R8302pZx",
"organizationalTarget": "urn:li:organization:1000"
}
]
}
source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-access-control#find-access-control-information

How to "Add guest" to event via google calendar API?

could you please give me a hint on how to share a single event via google calendar api?
That is I'd like to invite other users to see the event programmatically without sharing the whole calendar. To mimic the "Add guests" UI action
As Claudio mentioned, you need to use the Google Calendar Advanced API for this.
You'll want to use a patch because you don't want to replace all the other data on the calendar invite. However, even in the case of patch, since the attendees lives in an array, if you attempt to pass a patch such as this:
{
attendees: [ { email: "new#example.com"} ]
}
... it'll replace all old invitees (i.e. it'll remove anyone that was on the invite before you called patch). To fix this, you must first get the current invitees, add a new person to the array, and then send a patch.
You can see a detailed example of this in this answer which also explains how to use Google Apps Scripting to ensure an email is sent to the user when adding them to a calendar event (see the addGuestAndSendEmail() method in that post).
You can use the API to add people to the attendees collection:
https://developers.google.com/google-apps/calendar/v3/reference/events/update
refer the following request.
method: POST
endpoint: https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all
here, sendUpdates means when you add any guest so he would get an invitation mail used based on scenario.
Input Json:
{
"kind": "calendar#event",
"etag": "etag",
"status": "confirmed",
"summary": "JayKara",
"description": "eqwbdjhwhhwhhwrhjehrhejhfj",
"location": "America",
"creator": {
"email": "#mail.com",
"self": true
},
"organizer": {
"email": "#mail.com",
"self": true
},
"start": {
"date": "2019-12-23"
},
"end": {
"date": "2019-12-24"
},
"originalStartTime": {
"date": "2019-12-24"
},
"visibility": "public",
"attendees": [
{
"email": "****#mail.com" //this guys are the guest
}
]
}.
After that there is no patch method required your guest guys will receive an invitation whenever update event
Cheers!

Resources