I am trying to get the URL of all the media inside of an organization post but all I can get is the image URN. I don't want to do another request to get the image but rather get the Posts information and the URL on the same call.
I tried to use the Posts API as the UGC Post API is currently marked as Legacy.
let testresp = await axios.get(https://api.linkedin.com/rest/posts?q=author&author=`urn%3Ali%3Aorganization%3A${LinkedInHelpers.URNtoID(orgsRes.data.elements[0].organizationalTarget)}`&fields=id,content:(media), {
headers: {
'Authorization': `Bearer ${accessToken.data.access_token}`,
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202301'
}
})
I also tried to use the ~
decorator to get extra data on the Media but it returns an empty object.
Hello please try making the get request add this address instead https://api.linkedin.com/v2/ugcPosts/${postId}
Try this:
axios.get(`https://api.linkedin.com/v2/ugcPosts/${postId}`, { headers })
.then((res) => {
const imgUrl = res.data.media_url;
console.log(imgUrl);
})
.catch((e) => {
console.error(e);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.