Skip to content

LinkedIn Posts with Images Fail with BadBody ErrorΒ #1058

@ksingh-scogo

Description

@ksingh-scogo

πŸ“œ Description

LinkedIn posts with images fail to publish, while text-only posts work correctly. X (Twitter) posts with images work fine using the same setup.

Error in logs:

[Error] posting on linkedin linkedin {} {} BadBody { identifier: 'linkedin', json: '{}', body: {}, message: '' }

πŸ‘Ÿ Reproduction steps

  1. Setup Postiz with Docker Compose

    docker compose up -d
  2. Configure ngrok for HTTPS URL

    ngrok http 5001
    • Update all URL environment variables to use ngrok HTTPS URL
    • Set NOT_SECURED=false
  3. Connect LinkedIn Account

    • Create LinkedIn Developer App
    • Add "Share on LinkedIn" product
    • Configure OAuth redirect URI
    • Add credentials to .env
    • Connect LinkedIn account through Postiz UI
    • βœ… Connection succeeds
  4. Schedule Text-Only Post to LinkedIn

    • Create post with only text content
    • Schedule for immediate or future time
    • βœ… Result: Post publishes successfully
  5. Schedule Post with Image to LinkedIn

    • Create post with text + image attachment
    • Image uploads successfully to /uploads/ directory
    • Image URL generated as: https://[ngrok-url].ngrok-free.app/uploads/2025/11/09/[filename].png
    • Schedule for immediate or future time
    • ❌ Result: Post fails with BadBody error

πŸ‘ Expected behavior

LinkedIn posts with images should publish successfully, similar to how X (Twitter) posts with images work.

πŸ‘Ž Actual Behavior with Screenshots

LinkedIn posts with images fail immediately when the worker processes them:

3|workers  | processing { id: 'cmhs4pa7l0003pk1c1lyrdseu', delay: 146144 }
3|workers  | [Error] posting on linkedin linkedin {} {} BadBody {
  identifier: 'linkedin',
  json: '{}',
  body: {},
  message: ''
}

The body: {} indicates the request body is empty, suggesting the worker failed to construct the LinkedIn API request with the image.

πŸ’» Operating system

MacOS

πŸ€– Node Version

the docker version

πŸ“ƒ Provide any additional context for the Bug.

Environment

  • Postiz Version: ghcr.io/gitroomhq/postiz-app:latest (as of Nov 9, 2025)
  • Deployment: Docker Compose (single container with all services)
  • OS: macOS (Darwin 24.1.0)
  • Database: PostgreSQL 17-alpine
  • Redis: 7.2-alpine
  • URL Setup: ngrok tunnel (HTTPS)

Configuration

# docker-compose.yml
services:
  postiz:
    image: ghcr.io/gitroomhq/postiz-app:latest
    ports:
      - "5001:5000"
    volumes:
      - ./uploads:/uploads/
    env_file: .env

Environment Variables

MAIN_URL=https://[ngrok-url].ngrok-free.app
FRONTEND_URL=https://[ngrok-url].ngrok-free.app
NEXT_PUBLIC_BACKEND_URL=https://[ngrok-url].ngrok-free.app/api
BACKEND_INTERNAL_URL=http://localhost:3000
NOT_SECURED=false
STORAGE_PROVIDER=local
UPLOAD_DIRECTORY=/uploads/
NEXT_PUBLIC_UPLOAD_DIRECTORY=/uploads/

# LinkedIn OAuth 1.0a Credentials
LINKEDIN_CLIENT_ID=AAAAAAAAAA
LINKEDIN_CLIENT_SECRET=BBBBBBBBBB

LinkedIn App Configuration

  • OAuth 2.0 Products Added:
    • "Share on LinkedIn" (Default Tier)
    • "Sign In with LinkedIn using OpenID Connect" (Standard Tier)
  • Status: Products added but not yet verified (no green checkmark)
  • Redirect URI: https://[ngrok-url].ngrok-free.app/integrations/social/linkedin
  • Account Type: Personal LinkedIn profile

What Works

βœ… Text-only LinkedIn posts - Publish successfully
βœ… X (Twitter) posts with images - Publish successfully using same ngrok URL
βœ… X (Twitter) text-only posts - Publish successfully
βœ… LinkedIn OAuth connection - Authentication works correctly
βœ… Image upload to Postiz - Images save correctly to /uploads/ directory
βœ… Image URL accessibility - Images accessible via ngrok URL from browser and container

What Fails

❌ LinkedIn posts with images - Fail with empty BadBody error

Troubleshooting Performed

1. βœ… Verified Image URL Accessibility

  • Images are accessible at https://[ngrok-url].ngrok-free.app/uploads/...
  • Tested from browser: βœ… Works
  • Tested from inside container: βœ… Works
docker exec postiz-app wget -O- https://[ngrok-url].ngrok-free.app/uploads/2025/11/09/test.png
# Success: 200 OK

2. βœ… Verified OAuth Configuration

  • LinkedIn app redirect URI matches Postiz configuration
  • OAuth 2.0 flow works (can connect LinkedIn account)
  • Access tokens are generated successfully
  • Tested manual OAuth URL - redirects correctly

3. βœ… Verified Worker Process

  • Worker service is running correctly
  • Text-only posts process successfully
  • X posts with images process successfully
  • Only LinkedIn + images combination fails

4. βœ… Checked Log Details

Post data structure shows image path is correctly included:

{
  "integration": { "id": "cmhs4jnki0001pk1cnslfx7hn" },
  "value": [{
    "content": "<p>Test post</p>",
    "image": [{
      "id": "91e341dd-4a25-48b6-8e3c-aa67503f22f1",
      "path": "https://[ngrok-url].ngrok-free.app/uploads/2025/11/09/[filename].png"
    }]
  }]
}

5. ⚠️ LinkedIn Product Verification Status

  • "Share on LinkedIn" product shows "Default Tier" but no green checkmark
  • Product is added but not yet verified by LinkedIn
  • However, text-only posts work, suggesting basic posting permission exists
  • Question: Does image posting require additional LinkedIn product verification?

Comparison with X (Twitter)

The same setup works perfectly for X posts with images:

  • Same ngrok URL configuration
  • Same /uploads/ directory and volume mount
  • Same Docker container and worker process
  • Images successfully uploaded to X API

This suggests the issue is specific to LinkedIn's image handling code in Postiz.

Suspected Root Cause

Based on the empty body: {} in the error, the likely causes are:

  1. LinkedIn API image upload flow differs from X:

    • X: Direct image upload with post
    • LinkedIn: Might require separate image upload first, then reference in post
  2. Missing LinkedIn permissions:

    • The unverified "Share on LinkedIn" product might lack image upload permissions
    • Text posting works but media posting might require additional approval
  3. Bug in Postiz LinkedIn provider:

    • Image download/processing fails
    • LinkedIn API request construction fails when images are present
    • Error handling doesn't provide detailed error message

Relevant Code Location

Based on logs, the error originates from:

/app/apps/backend/dist/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.js

Additional Context

Timeline of Events

  1. βœ… Postiz setup and X integration working (text + images)
  2. βœ… LinkedIn app created and configured
  3. βœ… LinkedIn account connected through Postiz
  4. βœ… Text-only LinkedIn post scheduled and published successfully
  5. ❌ LinkedIn post with image scheduled but failed to publish

Worker Behavior

  • Worker picks up the job: processing { id: '...', delay: 146144 }
  • Immediately fails with BadBody error
  • No retry attempts
  • No detailed error message about what failed

Environment Variable Evolution

We tried multiple URL configurations before finding the ngrok solution:

  • ❌ localhost:5001 - Worker couldn't access from inside container
  • ❌ 127.0.0.1:5000 - Host port conflict with macOS ControlCenter
  • βœ… ngrok HTTPS URL - Works for X, partially works for LinkedIn

Questions for Maintainers

  1. Does LinkedIn image posting require the "Advertising API" product to be approved?

    • We requested it but it's pending approval
  2. Is there additional logging we can enable to see the actual LinkedIn API error?

    • The BadBody error with empty body: {} doesn't provide details
  3. Does Postiz handle LinkedIn's two-step image upload process?

    • Register upload
    • Upload binary
    • Reference in post
  4. Are there known issues with LinkedIn image uploads in the current version?

Workaround

For now, we're using:

  • LinkedIn for text-only posts βœ…
  • X (Twitter) for posts with images βœ…

Logs

Full error sequence:

0|backend  | {
0|backend  |   "type": "schedule",
0|backend  |   "posts": [{
0|backend  |     "integration": { "id": "cmhs4jnki0001pk1cnslfx7hn" },
0|backend  |     "value": [{
0|backend  |       "content": "<p>Test post with image</p>",
0|backend  |       "image": [{
0|backend  |         "id": "91e341dd-4a25-48b6-8e3c-aa67503f22f1",
0|backend  |         "path": "https://[ngrok-url].ngrok-free.app/uploads/2025/11/09/test.png"
0|backend  |       }]
0|backend  |     }]
0|backend  |   }]
0|backend  | }
0|backend  | event to dispatch: {
0|backend  |   pattern: 'post',
0|backend  |   data: { id: 'cmhs4pa7l0003pk1c1lyrdseu', options: { delay: 146144 } }
0|backend  | }
3|workers  | processing { id: 'cmhs4pa7l0003pk1c1lyrdseu', delay: 146144 }
3|workers  | [Error] posting on linkedin linkedin {} {} BadBody {
  identifier: 'linkedin',
  json: '{}',
  body: {},
  message: ''
}

System Information

# Docker Compose version
Docker Compose version v2.x

# Container logs show
Nest application successfully started
πŸš€ Backend is running on: http://localhost:3000

# All services running
0|backend  - Backend process
1|frontend - Next.js frontend
2|workers  - Worker process
3|cron     - Cron jobs

Related Issues: (Search for similar LinkedIn image issues)

Would appreciate any guidance on:

  1. Enabling more detailed LinkedIn API error logging
  2. LinkedIn product verification requirements for image posting
  3. Whether this is a known limitation or bug

Thank you for maintaining Postiz! πŸ™

πŸ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions