Skip to main content

Httpie

GET

#!/bin/bash

if
http
--check-status
--ignore-stdin
--timeout=10
--raw "{\"options\": { \"method\": \"GET\",\"headers\": {\"Content-Type\": \"application/json\",\"Accept\": \"application/json\"}}, \"url\": \"/rest/api/3/issue/DEV-16\"}"
POST <YOUR ENDPOINT URL> \apikey:"< YOURTOKEN >" ; then
echo 'OK!'
else
case $? in
2) echo 'Request timed out!' ;;
3) echo 'Unexpected HTTP 3xx Redirection!' ;;
4) echo 'HTTP 4xx Client Error!' ;;
5) echo 'HTTP 5xx Server Error!' ;;
6) echo 'Exceeded --max-redirects=<n> redirects!' ;;
*) echo 'Other Error!' ;;
esac
fi

POST

#!/bin/bash

if
http
--check-status
--ignore-stdin
--timeout=10
--raw "{
\"options\": {
\"method\": \"POST\",
\"headers\": {
\"Content-Type\": \"application/json\",
\"Accept\": \"application/json\"
},
\"body\": {
\"fields\": {
\"project\":{
\"name\": \"<your project name>\"
},
\"summary\": \"Create Issue via POST.\",
\"description\": \"Creating of an issue via a POST request using the API Key Manager\",
\"issuetype\": {
\"id\": \"<your issue type id>\"
}
}
}
},
\"url\": \"/rest/api/2/issue\"
}"
POST <YOUR ENDPOINT URL> \apikey:"< YOURTOKEN >" ; then
echo 'OK!'
else
case $? in
2) echo 'Request timed out!' ;;
3) echo 'Unexpected HTTP 3xx Redirection!' ;;
4) echo 'HTTP 4xx Client Error!' ;;
5) echo 'HTTP 5xx Server Error!' ;;
6) echo 'Exceeded --max-redirects=<n> redirects!' ;;
*) echo 'Other Error!' ;;
esac
fi