400/checkout/session, /subscription/change/preview, /subscription/change, /playground/*

Invalid JSON body

How to fix the Scrnpix API error when the request body contains malformed or invalid JSON.

When Does This Happen?

This error occurs when a POST endpoint expects a JSON request body but receives content that cannot be parsed as valid JSON. This applies to billing endpoints (/checkout/session, /subscription/change/preview, /subscription/change) and playground endpoints (/playground/screenshot, /playground/animate). Note that /screenshot and /animate use query parameters, not request bodies.

Reproduce This Error

curl -X POST -H "Cookie: session=your-jwt" \
  -H "Content-Type: application/json" \
  -d '{invalid json}' \
  "https://api.scrnpix.com/checkout/session"
{"error": "Invalid JSON body"}

How to Fix

  1. 1Validate your JSON syntax using a JSON linter before sending
  2. 2Set the Content-Type header to application/json
  3. 3Ensure all strings are double-quoted (JSON does not allow single quotes)
  4. 4Check for trailing commas, which are not valid in JSON

Correct Request

curl -X POST -H "Cookie: session=your-jwt" \
  -H "Content-Type: application/json" \
  -d '{"planId": "STRIPE_PRICE_BASIC"}' \
  "https://api.scrnpix.com/checkout/session"
{"url": "https://checkout.stripe.com/..."}

Related Errors

Frequently Asked Questions

Do the /screenshot and /animate endpoints require a JSON body?

No. The /screenshot and /animate endpoints accept all parameters as query strings on GET requests. Only POST endpoints like /checkout/session and /subscription/change require a JSON request body.

Still Having Issues?

Check your API key and subscription status in the dashboard, or explore our language guides for integration examples.

Go to Dashboard