I'm trying to create variable with json value in Airflow using web api.
My script:
curl -X POST "${AIRFLOW_URL}/api/v1/variables" \
-H "Content-Type: application/json" \
--user "${AIRFLOW_USERNAME}:${AIRFLOW_PASSWORD}" \
-d '{"key": "my_json_var", "value": {"key1":"val1","key2":"123"}}'
But it doesn't work. I get 400 status:
{
"detail": "{'key1': 'val1', 'key2': '123'} is not of type 'string' - 'value'",
"status": 400,
"title": "Bad Request",
"type": "https://airflow.apache.org/docs/apache-airflow/2.7.1/stable-rest-api-ref.html#section/Errors/BadRequest"
}
What am I doing wrong?
ps. I tried using python with requests and got the same result. I think the problem is in the airflow web api. Perhaps their methods don't support adding json variables