I am working with the LinkedIn Shares API and I use the below code to share content to LinkedIn. The problem is that if the text contains a video link or image link, LinkedIn doesn't know how to grab the Link from the text and show a Preview of the image or video.
E.g imagine the text says
Hello world and has an embedded YouTube Link Like this and more text here
How can I make LinkedIn pick up the YouTube link from the text and preview it?
Here is my code:
let postUrl = `https://api.linkedin.com/v2/shares`;
let headers = {
'Authorization': `Bearer ${access_token}`,
'X-Restli-Protocol-Version': '2.0.0'
};
let requestBody = {
text: {
text: `Hello world and has an embedded **[YouTube Link Like this][1]** and more text here`
},
"distribution": {
"linkedInDistributionTarget": {}
},
owner: `urn:li:organization:${organization.id}`
};
let pagePostResponse = await axios.post(postUrl, requestBody, {
headers: headers
});
//The content gets posted successfully to LinkedIn but the youtube link preview is not showing
Thank you