TedroyG
TedroyG

Reputation: 49

How to query a user name by a email address in Jira Rest API

I want to create issues in Jira based on Outlook emails received using VBA. However, when setting the assignee/reporter via the REST API it appears that users can only be specified by name. When trying to specify a user by email address I get this error:

assignee: expected Object containing a 'name' property

Here is the Json code that is not working:

JSON(0) = "{"
JSON(1) = "  ""fields"": {"
JSON(2) = "    ""project"": {"
JSON(3) = "      ""id"": 23354"
JSON(4) = "    },"
JSON(5) = "    ""summary"": ""@customSubject"","
JSON(6) = "    ""description"": ""@customBody"","
JSON(7) = "    ""issuetype"": {"
JSON(8) = "      ""name"": ""@issueName"""
JSON(9) = "    },"
JSON(10) = "    ""assignee"": {"
JSON(11) = "      ""emailAddress"": ""@assignEmail"""
JSON(12) = "    },"
JSON(13) = "    ""labels"": ["
JSON(14) = "      ""@jiraLabel"""
JSON(15) = "    ]"
JSON(16) = "  }"
JSON(17) = "}"

JSON = getJSON(CustomReplace(OutlookMail.Subject), CustomReplace(OutlookMail.Body), "Ticket", CustomReplace(OutlookMail.SenderName), "")

Do you have any idea how can I make this work with email address instead of name?

This is working:

JSON(0) = "{"
JSON(1) = "  ""fields"": {"
JSON(2) = "    ""project"": {"
JSON(3) = "      ""id"": 23354"
JSON(4) = "    },"
JSON(5) = "    ""summary"": ""@customSubject"","
JSON(6) = "    ""description"": ""@customBody"","
JSON(7) = "    ""issuetype"": {"
JSON(8) = "      ""name"": ""@issueName"""
JSON(9) = "    },"
JSON(10) = "    ""assignee"": {"
JSON(11) = "      ""name"": ""@assignAlias"""
JSON(12) = "    },"
JSON(13) = "    ""labels"": ["
JSON(14) = "      ""@jiraLabel"""
JSON(15) = "    ]"
JSON(16) = "  }"
JSON(17) = "}"

JSON = getJSON(CustomReplace(OutlookMail.Subject), CustomReplace(OutlookMail.Body), "Ticket", "myusername", "")

Upvotes: 0

Views: 1398

Answers (1)

David Bakkers
David Bakkers

Reputation: 555

The ability to use usernames / email addresses for assignees / reporters for issues was deprecated years and years ago and replaced with using accountIDs. If you don't know a person's accountID, you have to search for it based on their username / email address.

Upvotes: 1

Related Questions