I am trying to track my user's AI word usage

This is my error message and my workflow action

The service Claude API - MarketOvergrowthYouTube.ai just returned an error (HTTP 400). Please consult their documentation to ensure your call is setup properly. Raw error:

{“type”:“error”,“error”:{“type”:“invalid_request_error”,“message”:“The request body is not valid JSON: unexpected character: line 7 column 268 (char 439)”}}

The error is coming from the Step 2 API call, most likely something the user typed broke it with an invalid character. Make sure to follow whatever the user types with a :format as JSON safe operator. This adds double quotes on each side and escapes any characters that will break it

It didn’t get to the step in your screenshot even because the API call returned an error

Also if the API returns the output tokens maybe that would be better to gauge cost for your users? Store it as a number in your database and when you charge them sum up the input + output tokens for the month * whatever dollar amount.

I have changed all of the data inputs to formatted for JSON. I got this error

The service Claude API - MarketOvergrowthYouTube.ai just returned an error (HTTP 400). Please consult their documentation to ensure your call is setup properly. Raw error:

{“type”:“error”,“error”:{“type”:“invalid_request_error”,“message”:“The request body is not valid JSON: unexpected character: line 7 column 90 (char 261)”}}

Do you know what’s causing it? Please help!

can you share your setup in the API Connector body, and also what the text you sent was? it just looks like a character is breaking the API call



Here’s my API and JSON

Holy :face_with_symbols_over_mouth: yes this makes sense why it’s not working :rofl: Your text has punctuation and stuff breaking it.

Just simplify the content portion into "content": <content> (save your prompt in a text editor before deleting)

Then when you do the API call set content to Arbitrary text:format as JSON safe

Inside the Arbtrary text paste all of that in there then highlight the dynamic parts like <Business_Locations> and insert dynamic data instead. And the //n//n stuff at the end put actual line breaks instead.

Is there anyway to do it with keeping the prompt intact? The app only breaks when I try measuring usage if I remove that action from the workflow everything works.

the error is coming from the API call so it looks like the error would always be happening… :thinking:

It’s kind of an issue right now because technically the JSON formatting is fine but if any of those values in the placeholders have a character like a newline, double quote, backslash (and more) then it will break it. It is best to just wrap the whole thing like I mentioned.

Have you tried it with super basic placeholders? Like put the letter A for everything and see what happens :joy: