Ruby Jira - Issues: Assign Issue

Back to Index

Assigns the issue to the user. Use this resource to assign issues for the users having “Assign Issue” permission, and not having the “Edit Issue” permission. If name body parameter is set to “-1” then automatic issue assignee is used. A name set to null will remove the assignee. A successful response is indicated by a 204 status code with no response body. This example assigns issue "SCRUM-15" to "matt"

Documentation: https://developers.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-assignee-put

CURL Command

curl -X PUT --user jira@example.com:JIRA_API_TOKEN \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '
    {
      "name": "matt"
    }' \
  --url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/assignee'

Ruby Example

require 'chilkat'

rest = Chilkat::CkRest.new()

#  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/assignee
bTls = true
port = 443
bAutoReconnect = true
success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect)
if (success != true)
    print "ConnectFailReason: " + rest.get_ConnectFailReason().to_s() + "\n";
    print rest.lastErrorText() + "\n";
    exit
end

rest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN")

json = Chilkat::CkJsonObject.new()
json.UpdateString("name","matt")

rest.AddHeader("Content-Type","application/json")
rest.AddHeader("Accept","application/json")

sbRequestBody = Chilkat::CkStringBuilder.new()
json.EmitSb(sbRequestBody)
sbResponseBody = Chilkat::CkStringBuilder.new()
success = rest.FullRequestSb("PUT","/rest/api/2/issue/SCRUM-15/assignee",sbRequestBody,sbResponseBody)
if (success != true)
    print rest.lastErrorText() + "\n";
    exit
end

respStatusCode = rest.get_ResponseStatusCode()
if (respStatusCode >= 400)
    print "Response Status Code = " + respStatusCode.to_s() + "\n";
    print "Response Header:" + "\n";
    print rest.responseHeader() + "\n";
    print "Response Body:" + "\n";
    print sbResponseBody.getAsString() + "\n";
    exit
end