Skip to main content

Ruby

GET

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("<YOUR ENDPOINT URL>")

header = {"apiKey": "<YOURTOKEN>"}
body = {
"options": {
"method": "GET",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
}
},
"url": "/rest/api/3/issue/TEST-1"
}

# Create the HTTP objects

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = body.to_json

# Send the request

response = http.request(request)

puts response.body

POST

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("<YOUR ENDPOINT URL>")

header = {"apiKey": "<YOURTOKEN>"}
body = {
"options": {
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
},
"body": {
"fields": {
"project":{
#or you can use "id": "<your project id>"
"name": "<your project name>"
},
"summary": "Create Issue via POST.",
"description": "Creating of an issue via a POST request using the API Key Manager",
"issuetype": {
#or you can use "name": "<your issue type name>"
"id": "<your issue type id>"
}
}
}
},
"url": "/rest/api/2/issue"
}

# Create the HTTP objects

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = body.to_json

# Send the request

response = http.request(request)

puts response.body