LinkedIn api post creation via HTTP request node error with text format

Describe the problem/error/question

I’m using AI nodes to generate somne text to [post to my LinkedIn, I’ve tested the credential yusing the http request GET so I know that works.
When trying to create the post for the AI generated text, I constantly get errors such as:
400 - “{"status":400,"code":"ILLEGAL_ARGUMENT","message":"Request body could not be converted to data map"}”
Full message
422 - “{"message":"ERROR :: /## Audit Log Ingestion Lag\n\nImagine you’re trying to catch a thief who just left a store :: unrecognized field found but not allowed\nERROR :: /author :: field is required but not found and has no default value\nERROR :: /commentary :: field is required but not found and has no default value\nERROR :: /visibility :: field is required but not found and has no default value\nERROR :: /distribution :: field is required but not found and has no default value\nERROR :: /lifecycleState :: field is required but not found and has no default value\n","status":422}”

Please share your workflow

Unable to copy the nodes, doesn't seem to copy the text (Edge on Windows 11)
Al nodes work OK, it's just the LinkedIn posting via HTTP request that's not posting

Share the output returned by the last node

422 - “{"message":"ERROR :: /## Audit Log Ingestion Lag\n\nImagine you’re trying to catch a thief who just left a store :: unrecognized field found but not allowed\nERROR :: /author :: field is required but not found and has no default value\nERROR :: /commentary :: field is required but not found and has no default value\nERROR :: /visibility :: field is required but not found and has no default value\nERROR :: /distribution :: field is required but not found and has no default value\nERROR :: /lifecycleState :: field is required but not found and has no default value\n","status":422}”

Information on your n8n setup

  • n8n version: 2.30.0
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Proxmox lxc
  • Operating system: Proxmox

Thanks for letting us know about this, We have created CV-9 as the internal dev ticket to look into it.

OK, I’ve managed to resolve the issues, it was LinkedIn API posting that requires certain fields to be added in the body for the post.

I also found that there is a 4000 character limit when posting via the API.

Both errors point to the same two root causes, and they are fixable:

  1. The 400 “Request body could not be converted to data map” means the JSON body itself is invalid — your AI text is being injected raw, so its quotes, newlines and characters like : and # break the JSON. Fix: set the HTTP Request body to JSON mode and wrap the text with JSON.stringify so it gets escaped, e.g. the commentary value becomes ={{ JSON.stringify($json.text) }} (drop the outer quotes in the template). That alone kills the “converted to data map” error.

  2. The 422 “field is required” list (author, commentary, visibility, distribution, lifecycleState) means you are posting to the newer /rest/posts endpoint but sending a partial body. That endpoint requires ALL of these. A minimal working body:

{
“author”: “urn:li:person:XXXX”, // or urn:li:organization:XXXX
“commentary”: “your text here”,
“visibility”: “PUBLIC”,
“distribution”: {
“feedDistribution”: “MAIN_FEED”,
“targetEntities”: ,
“thirdPartyDistributionChannels”:
},
“lifecycleState”: “PUBLISHED”,
“isReshareDisabledByAuthor”: false
}

And two headers people usually miss: LinkedIn-Version: 202401 (use a current YYYYMM) and X-Restli-Protocol-Version: 2.0.0. Without the version header LinkedIn silently rejects the schema.

One more gotcha specific to the /rest/posts commentary field: it uses LinkedIn’s “Little Text” format, so literal (, ), <, >, @, #, * and a few others must be escaped with a backslash or the request 422s. If your AI text contains markdown headers (##) or parentheses, strip or escape them before sending. Your example text had ## and :: in it, which is almost certainly what tipped it over.

If you paste the exact node config (endpoint URL + which fields you send) I can point at the specific missing piece.

We have taken a look at this issue and are unable to confirm that this is a bug, For now we have closed the internal ticket but if it starts to look like it is a bug our moderation team will flag this again.

Good find! For anyone landing here with the same issue, here’s the minimum required body for LinkedIn’s ugcPosts endpoint:

{
  "author": "urn:li:person:YOUR_PERSON_ID",
  "lifecycleState": "PUBLISHED",
  "specificContent": {
    "com.linkedin.ugc.ShareContent": {
      "shareCommentary": {
        "text": "Your post text here"
      },
      "shareMediaCategory": "NONE"
    }
  },
  "visibility": {
    "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
  }
}

Also worth noting: the 4000 character limit applies to the text field. If you’re using AI to generate content, add a length check before sending — otherwise the API will just reject the request silently.