我正在尝试使用Web API在Airflow中创建具有JSON值的变量。
我的剧本:
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"}}'
字符串
但它不起作用。我得到400个状态:
{
"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"
}
型
我做错了什么?
ps.我试着用python带请求,也得到了同样的结果,我觉得问题出在airflow web API上,可能他们的方法不支持添加json变量
1条答案
按热度按时间jljoyd4f1#
气流API没有问题,它接受一个变量值作为一个字符串,如文档中所述,您可以查看https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_variables
你应该把变量的值改为字符串,这样就可以了
字符串