[BUG] API Error: "invalid_request_error" "The request body is not valid JSON"
<img width="935" height="868" alt="Image" src="https://github.com/user-attachments/assets/670a3642-df71-4408-8f39-679664c3aa26" />
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.
27 Comments
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
sudoSo you'll have to
rm -rf _your directory___ lib/node_modules/@anthropic-ai/claude-codereinsall it using
npm install -g @anthropic-ai/claude-codethen
claude migrate-installerI never used sudo was working then suddenly died on me with a similar error:
I had to exit CC then start again by typing
claudein 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:
\exportthe session and then start a new one and say in the new oneResume 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 (char54840)"}}
Environment Info
Errors
The same just happened to me in Windows 11 with CC 1.0.72. Worked around it with the `
/export` methodI 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:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Temporar Fix:
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:
"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),
/exportworked thanks @sammywachtelI 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.
:( the same problem using macosx. Emoji based file break all.
Any solution or quick fixes folks, the issue seems to persist !!
PS : The dump workaround for me was to go back a few messages (press esc go 3-4 messages back) and restart that convo with either copy + pasted context from earlier or just start a fresh one !!!
But would be great to get this fixed !!
This is happening for me as well. Any update?
We get similar issue in our chatbot connected to claude api - the issue was that in the prompt we were sending snippet of csv file that contained utf-8 BOM header. After stripping the BOM header, the error disappeared.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.