通过API为TFE工作空间添加环境变量的JSON格式纠错求助
错误原因说明
- 原JSON存在语法错误:同级JSON对象中不能存在重复的
data键,且各个同级键值对之间缺少逗号分隔 - 不符合TFE/TF Cloud批量创建工作空间变量的API规范:批量新增变量时顶层
data字段需要定义为数组格式,每个数组元素对应一个变量的配置
修正后可用的JSON代码
{ "data": [ { "type": "vars", "attributes": { "key": "ID1", "value": "xxxxxx", "description": "", "category": "terraform", "hcl": false, "sensitive": false } }, { "type": "vars", "attributes": { "key": "ID2", "value": "xxxxxx", "description": "", "category": "terraform", "hcl": false, "sensitive": false } }, { "type": "vars", "attributes": { "key": "ID3", "value": "xxxxxx", "description": "", "category": "terraform", "hcl": false, "sensitive": true } }, { "type": "vars", "attributes": { "key": "ID4", "value": "xxxxxx", "description": "", "category": "terraform", "hcl": false, "sensitive": true } } ] }
补充说明
如果是调用单变量创建接口,一次只能传一个变量的配置,不需要用数组,每次请求只保留一个data对象即可。
内容的提问来源于stack exchange,提问作者Tuscani
相关产品推荐
相关产品推荐

