Hey everyone, I am building an app and have an Anthropic API call set up and working perfectly with hardcoded text in the body. I am now trying to make it dynamic by inserting text from a Multiline Input element into the JSON body.
I have added<contract_text>as a parameter placeholder in my API body like this:
“content”: “CONTRACT TEXT: <contract_text>” In my workflow Step 2 (the API call) I set contract_text = Multiline Input A’s value dynamically.
When I run it I get a HTTP 400 error: “The request body is not valid JSON: unexpected content after document”
I believe the issue is that the pasted text contains special characters like apostrophes, line breaks and quotes that are breaking the JSON structure when inserted dynamically.
Questions:
-
Is there a way to sanitise or escape the text before it is inserted into the JSON body?
-
Should I be using the Toolbox plugin to build the JSON body dynamically instead?
-
Is there a better pattern for sending large blocks of user-inputted text to an external API via Bubble?
Any help appreciated — the API call itself works perfectly with static text so this is purely a dynamic insertion problem