我正在编写一个简单shell脚本,当使用curl满足条件时,我将使用该脚本在JIRA中创建请求。以下是JIRA执行它的方式,需要我使用数据文件将请求作为命令和参数发送:
请求:
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
数据:
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
}}}
所以我不想使用如上所示的单独的数据文件。相反,我希望使用单个curl请求,该请求中嵌入了数据。类似于:
curl -D- -u fred:fred -X POST --"**PASS ALL MY DATA HERE**" -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
我知道这会让事情变得一团糟,但这正是我想要的。你能建议一下以上方法是否可行吗。
你能用here文档完成吗?
curl -D- -u fred:fred -X POST -d - -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/ <<EOF
{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
}}}
EOF