擅长:python、mysql、java
<p>感谢@wholevinski的回答(在问题评论中)。我需要将json更改为数据并添加标题。此外,我还需要执行\n循环</p>
<pre><code>payload = [{},
{"query": {"bool": {"filter": [{"terms": {"user_id": [504401]}}]}}, "size": 0},
{},
{"query": {"bool": {"filter": [{"terms": {"user_id": [504401]}}]}}, "size": 0}
] # same as in question
data_as_str = ""
for d in payload:
data_as_str += json.dumps(d) + "\n"
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
# "Accept: text/plain" may not be necessary
r = requests.post(url, headers=headers, auth=awsauth, data=data_as_str)
query_results = json.loads(r.text)
</code></pre>