我正在编写一个简单 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/
我知道它会让事情变得杂乱无章,但这就是我想要的方式。如果上述内容可行,请您说明一下。
答案 0 :(得分:1)
你能用here document做到吗?
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