Menu

Post image 1
Post image 2
1 / 2
0

Posting to LinkedIn From Node.js: 7 API Quirks That Burned Me

DEV Community·Nicolas Lecocq·25 days ago
#RdYrqjBu
#api#node#linkedin#webdev#user#fullscreen
Reading 0:00
15s threshold

I built a tool that posts to LinkedIn programmatically. Here is the list of things I wish I had known before I started, with code where it helps. None of these are documented prominently. All of them cost me an evening or two. 1. Author URN, not user ID When you create a UGC post, the API does not accept a user ID. It accepts a URN like urn:li:person:abc123 . If you store the LinkedIn user ID as a string and try to send it directly, you get a INVALID_AUTHOR error with no further detail. const authorUrn = `urn:li:person: ${ user . linkedinProfileId } ` ; Enter fullscreen mode Exit fullscreen mode For company pages, it is urn:li:organization:12345 . You must store the URN type along with the ID, or compute it at request time based on whether you are posting as a person or a company. 2. The image upload is three calls, not one You cannot just send a base64 image in the post body. The flow is: POST /rest/images?action=initializeUpload with the author URN. Response includes an uploadUrl and an image URN.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More