Rich media share - Unable to parse form content Linkedin API v2

182 Views Asked by At

While sharing a stored image works great (tried with postman). I could not make it work with an url of an image (SS3).

I have tried to send the URL as an URL, blob, buffer, base64 but each time I get this message in return 400: Unable to parse form content

Example of how I am trying to share as a blob.

const mediaUrl = https://d29fp8qybdwwik.cloudfront.net/bBKZjMgj6TZZwSJot/uE7Fjrk6BA-brooke-lark-500193-unsplash.jpg

const config = {
    headers: {
        Authorization: `Bearer ${accessToken}`
    }
};



const blob = await axios
    .get(mediaUrl, {
        responseType: 'blob'
    })
    .then(response =>
        response.data
    );

const url = 'https://api.linkedin.com/media/upload';
const data = new FormData();
data.append('fileupload', blob);
const response = await axios.post(url, data, config);

Any help would be appreciated.

PS: Linkedin's v2 API is a nightmare

0

There are 0 best solutions below