sumoheavy / jira-ruby

A Ruby gem for the JIRA REST API
MIT License
654 stars 412 forks source link

request: Bad Request when finding a user #409

Closed arcadia-okta closed 3 months ago

arcadia-okta commented 1 year ago

I am using jira-ruby version 2.3.0 and I have the following code:

client = JIRA::Client.new(options)
me = client.User.find(account_id)

I have the options variable set with site, username, password, etc. I am using a personal access token for authentication. I have tried using the UUID I find on my JIRA profile page as well as my email and full name.

I am able to use this client to retrieve a list of issues no problem, so I know it is configured correctly.

Ultimately, I want to be able to update the assignee field on issues. I have tried doing

issue.save({ "fields" => { "assignee" => { "name" => myname }}})

with a valid issue, but this doesn't work in spite of the result of this call being true. The reason I got to trying to find my user was to get the accountId value (to be certain I was understanding it right) since in the above code name is supposed to be accountId now.

bobbrodie commented 4 months ago

Hey @arcadia-okta I know it's been a long time since this was reported, I apologize. I'm working on numerous updates for a new release, and have been merging various PRs from community members.

This issue was due to the need of switching to accountId instead of username, as you've mentioned. The related PR fixes this so you can do the following:

# Get a user
# Note: You can get all users, loop through them, store them in a database, and then be able to reference more easily
user = client.User.find('5e17314b0af0d70e911d3917')

# Get an issue
issue = client.Issue.find('TP-1')

# Assign a user to the issue
issue.save({ 'fields' => { 'assignee' => { 'accountId' => '5e17314b0af0d70e911d3917' } } })

# Print out the info
puts issue.key
puts "Reporter: #{issue.reporter.displayName}"
puts "Assignee: #{issue.assignee.displayName}"

We can no longer query by username -- here is the deprecation notice related to the thread you've posted.