Skip to main content

Elixir

GET​

#! /usr/bin/env elixir
Mix.install([:hackney])

require Logger

defmodule ApiTestRequest do
def request do
{:ok, status, respHeaders, respBody} = :hackney.post('<YOUR ENDPOINT URL>', [{"Content-Type", "application/json"},{"apiKey", "<YOURTOKEN>"}],'{\"options\":{\"method\": \"GET\",\"headers\":{\"Content-Type\": \"application/json\",\"Accept\": \"application/json\"}},\"url\": \"/rest/api/3/issue/TTCL-16\"}', [:with_body])
Logger.info('Status: #{status}')
Logger.info(respHeaders)
Logger.info(respBody)
end
end

ApiTestRequest.request()

POST​

#! /usr/bin/env elixir
Mix.install([:hackney])

require Logger

defmodule ApiTestRequest do
def request do
{:ok, status, respHeaders, respBody} = :hackney.post('<YOUR ENDPOINT URL>', [{"Content-Type", "application/json"},{"apiKey", "<YOURTOKEN>"}],'{
\"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\"
}', [:with_body])
Logger.info('Status: #{status}')
Logger.info(respHeaders)
Logger.info(respBody)
end
end

ApiTestRequest.request()