Reputation: 2525
I am writing a simple shell script using which I will create a request in JIRA when conditions are met using curl. Following is the JIRA way of executing it, which needs me to send send the request as a command and parameters using a data file:
Request:
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
Data:
{
"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"
}}}
So I don't want to use a separate data file as shown above. Rather I would like to using a single curl Request which has the data embedded in the request. Something like:
curl -D- -u fred:fred -X POST --"**PASS ALL MY DATA HERE**" -H "Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
I know it will make things cluttered, but thats the way i want it. Can you please suggest if the above is feasible.
Upvotes: 0
Views: 706
Reputation: 73
Can you do it with a 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
Upvotes: 1