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.…