Hi,
I am using python client library to send post request.
Below is my code, when I send post reuest without osd-xsrf
header,
getting error - {"status": 400, "body": "Request must contain a osd-xsrf header."}
.
While after adding osd-xsrf=true
in header , then getting invalid syntax error
.
Code-
import requests
headers = { 'osd-xsrf':'true'}
data = {
"site_name": "XYZ",
"location": "ABC",
"latitude": "c",
"longitude": "d"
}
resp = requests.post('hostname:9200',headers=headers,data=data,verify=False)
print(resp)
print(resp.json)
print(resp.content)
print(resp.text)
Output Error-
File "<ipython-input-30-8918d81b837f>", line 3
headers = { 'osd-xsrf=true'}
^
SyntaxError: invalid syntax
Pls let me konw the syntax for header in python client for osd-xsrf:true
.
Ref link- Common issues - OpenSearch documentation