product translation failing with body_html contains <script> tag

Hello, I am writing a PHP code to translate product details to various other languages. my product details (field name body_html) is taking HTML. The below HTML code is passed and saved via GraphQL api call.

as you can see, i have used addslashes and jason_encode to escape special chars.

however, the moment i add below code to the above, it does not accept the input.

the problem was CR+LF (new line) characters in the post data, once i cleaned it, it worked.