Curl command not running from python script

I tried to run a curl command from a python script to fetch anomaly results. The code is as follows:
BODY= '{"size": 10000, "query": {"bool": {"filter": [{"term": {"result_type": "record"}},{"range": {"record_score": {"gte": 75}}},{ "range" : { "multi_bucket_impact" : { "lt": "-4" } } }]}},"script_fields": {"timestamp_date": {"script": {"lang": "painless","source": "doc["timestamp"]"}},"record_score" : {"script": {"lang": "painless","source": "doc["record_score"].value"}},"SHIPPERID_CARRIERID" : {"script": {"lang": "painless","source": "doc["partition_field_value"]"}}}}'

try:
output= subprocess.check_output(["curl","-g","-XGET", "http://localhost:9200/.ml-anomalies-.write-my_job_low_sum/_search" ,"-H" ,"Content-Type: application/json", "-d", BODY])
print(output)
except Exception as e :
print(e)

But I'm getting the full error:

{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:261] [script] failed to parse object"}],"type":"x_content_parse_exception","reason":"[1:261] [script] failed to parse object","caused_by":{"type":"json_parse_exception","reason":"Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@45adfb41; line: 1, column: 268]"}},"status":400}

Can you explain the cause for this error and how to solve it?

You probably need to escape the double-quotes of "timestamp" since they are inside other double quotes. So, like this:

"source": "doc[\"timestamp\"]"

Im still getting the error

Probably need to do the same thing for the other instances of the embedded double quotes, like for

"doc[\"record_score\"].value"

and

"doc[\"partition_field_value\"]"

I tried that too and I'm still getting that error

It may be a shot in the dark, but have you tried escaping the square brackets in those three values?