[BUG] API Error: "invalid_request_error" "The request body is not valid JSON"
Environment
- Platform: Anthropic Login
- Login Method: Claude Pro Account
- Claude CLI version: v1.0.56
- Model: Sonnet 4
- Operating System: Ubuntu 24.04
- Terminal: Ubuntu
Bug Description
Persistant following error message despite several different edit commands
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 42462 (char 42461)"}}
Expected Behavior
Not get the following error in midle of a very simple UI color changing task ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 42462 (char 42461)"}}
Actual Behavior
I plot code to change the UI color of my WebApp, which is written in TypeScript And it kept throwing the error after editing for few seconds.
I got this also, do you have any quick fix?
same bug. Please help
Whats the fix????
Guys! I figured it out!
When installing claude-code it's recommended you don't use sudo
So you'll have to rm -rf _your directory___ lib/node_modules/@anthropic-ai/claude-code
reinsall it using
npm install -g @anthropic-ai/claude-code
then
claude migrate-installer
I never used sudo was working then suddenly died on me with a similar error:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 360047 (char
360046)"}}
I had to exit CC then start again by typing claude in the project directory thankfully I was getting CC to plan everything first and document any/all actions in case similar happens.
Any news on this? I also have this problem now
API Error: 400 {"type":"error","error":{"type":"invalid_request_ error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 156085 (char 156084)"}}
It does seem that starting a new Claude Code session "fixes" it though
Same here. A workaround for me was to:
\export the session and then start a new one and say in the new one Resume the conversation in 2025-08-08-this-session-is-being-continued-from-a-previous-co.txt and let's continue with what we were in the middle of.
This picked up the conversation and got around the error. This suggests that something becomes corrupted in the session itself.
Bug Description
I keep getting the following error and I'm not sure what's causing it. API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON: no low surrogate in string: line 1 column 54841 (char 54840)"}}
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 1.0.71
- Feedback ID:
Errors
[{"error":"AxiosError: Request failed with status code 403\n at VN (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:682:1077)\n at Unzip.J0 (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:683:9955)\n at Unzip.emit (node:events:530:35)\n at Unzip.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1698:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:90:21)\n at $B1.request (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:685:2088)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async uK8 (file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2289:470)\n at async Promise.all (index 0)\n at async file:///Users/username/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2275:19497","timestamp":"2025-08-08T14:48:40.786Z"}]
The same just happened to me in Windows 11 with CC 1.0.72. Worked around it with the /export method
I encountered this exact same error today. The following solution worked for me, and I hope it will be helpful to you as well. Solution:
Step 1 - Type /status to find your claude code Session ID. Note it. Step 2 - CTR+C twice to exit the Claude session Step 3 - Restart terminal (or VS Code) Step 4 - Use one of the following options to resume your Claude session.
Type "claude --resume" (This command will list your previous Claude code conversations for you to select from.) claude -r "session-id" (resume specific session) claude -c (resume most recent session)
I also recorded a video to make it easy for you to follow. https://youtu.be/lAnaIz-uaek
Having same issue no matter how i restart the session, whatever i type in the prompt returns with same error even after restarting session
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/5889
- https://github.com/anthropics/claude-code/issues/1709
- https://github.com/anthropics/claude-code/issues/1832
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Temporar Fix:
- Quit claude
- In terminal run: rm -rf ~/.claude/cache
- Then run: rm -rf ~/.claude/tmp
- Then run: file -bi . | grep -v ascii
same issue
Any news on this? happening here too in the middle of a conversation for no clear reason. Claude developers around?
issue still exists as of Sep 11 2025
I’m experiencing the exact same issue.
The only way I can continue working is by starting a new session, as resuming or restarting the current one always fails with the same error:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON..."}}
It seems like the session itself gets corrupted, and I haven’t found any workaround other than creating a fresh session.
I have a workaround but to be honest I have not had any similar issues for a while now not since last commenting on this thread.
I suggest as you work ask CC to generate index files these are markdown files that tell it where everything is, what context file(s), where the code is, key points etc (this doc is useful to a developer as well as a jumping in point), then during your sessions when you get a pause ask it to record the session details for its future self to continue should you need to take a break.
This works relatively well for me for example I prompt like this:
Hi buddy can you enable beast mode see claude-code-warp-beast-mode.md then digest your CLAUDE.md context file and any/all documents in this solution finally understand the code base
see CODE_INDEX.md for reference then give me a plan of where we are and what was next on the planned sprints and tasks.
"BEAST MODE" is the infamous ChatGPT beast mode script that I adapted for Claude Code found here: LINK.
Its a little clunky but I found I was able to continue just fine most of the time especially when I have documents that capture any plans and the current plan (I plan often, execute a few times), any key points from a previous session e.g. we figured out how to do something or resolve a bug.
I have found since I keep my context sessions smaller I am not having issues (on Claude Code v1.0.113)
Bug is still happening (mac Claude Code v1.0.108), /export worked thanks @sammywachtel
I just got the same error, even though I tried some of the recommendations from here. The only step that worked was to start a brand-new session.
This is unacceptable for such a high price point.
This error repeatedly occurs for me when Claude Code edits files containing emojis on Debian, but I haven’t experienced it on macOS. Looking at the original bug report, it looks like they are also experiencing it on a file with Emojis on a Linux distro.