I have a problem trying to insert data as well using python…mind you i am a little bit of a novice. I can connect to the application fine:
STRAPI_API_KEY = os.environ["STRAPI_API_KEY"]
STRAPI_URL_ENDPOINT = f"http://192.168.0.35:1337/api/flight-datas"
STRAPI_HEADERS = {
"Authorization": f"Bearer {STRAPI_API_KEY}",
"Content-Type": "application/json"
}
Then with request:
def sheet_data_insert(self):
"""Insert data back into spreadsheet"""
schema = {
"data": {
"city": "Paris",
"iatacode": "",
"lowestprice": "42"
}
}
r = requests.post(url=STRAPI_URL_ENDPOINT, headers=self.auth_header, params=schema)
print(r.text)
I recieve this error:
{"data":null,"error":{"status":400,"name":"ValidationError","message":"Missing \"data\" payload in the request body","details":{}}}
Anyone point me in the right direction? I clearly have a “data” payload but is params not the request body?
This is the example value from the documentation so I am a little confused:
{
"data": {
"city": "string",
"iatacode": "string",
"lowestprice": "string"
}
}