【发布时间】:2017-08-16 13:55:56
【问题描述】:
嘿,我正在使用管道 curl 方法从帖子创建任务。当我从带有硬编码值的终端运行时,它工作正常。但是当我尝试用变量执行它时,它会抛出一个错误:
脚本:
#!/bin/bash
echo "$1"
echo "$2"
echo "$3"
echo "$4"
echo "$5"
echo '{
"transactions": [
{
"type": "title",
"value": "$1"
},
{
"type": "description",
"value": "$2"
},
{
"type": "status",
"value": "$3"
},
{
"type": "priority",
"value": "$4"
},
{
"type": "owner",
"value": "$5"
}
]
}' | arc call-conduit --conduit-uri https://mydomain.phacility.com/ --conduit-token mytoken maniphest.edit
执行:
./test.sh "test003 ticket from api post" "for testing" "open" "high" "ahsan"
输出:
test003 ticket from api post
for testing
open
high
ahsan
{"error":"ERR-CONDUIT-CORE","errorMessage":"ERR-CONDUIT-CORE: Validation errors:\n - User \"$5\" is not a valid user.\n - Task priority \"$4\" is not a valid task priority. Use a priority keyword to choose a task priority: unbreak, very, high, kinda, triage, normal, low, wish.","response":null}
正如您所看到的错误,它将 $4 和 $5 读取为值而不是变量。而且我无法理解如何在这些参数中使用 $variables 作为输入。
【问题讨论】:
标签: json bash curl environment-variables echo