Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using /issue/{issuekey}/notification REST endpoint, how to use email address

I'd like to send notifications using the following in the Users section:

  • Hard-coded email address
  • A text field holding an email address
  • A single user picker field
  • A  multiple user user picker
  • A singe or multiple group picker field

I don't see any way to do these things. Is there a way?

1 answer

1 accepted

Hello @Richard Scire 

Are you referring to the /rest/api/3/issue/{issueIdOrKey}/notify endpoint?

If so, can you provide the content of the POST request you're making to that endpoint, and the method / tool you're using to submit that request.

It's embedded in a Scriptrunner listener. Here is the code:

def resp = post("/rest/api/2/issue/${issueKey}/notify")
.header("Content-Type", "application/json")
.body([
subject : subject,
textBody: body,
htmlBody: "<p>${htmlBody}</p>",
to : [
users: [[
accountId : b2b_ops
]]
]
])
.asString()

I know I can include the assignee, reporter, groups and users. Can I add an email address or a text field that contains and email address?

Thanks for your help.

Hello @Richard Scire 

When you drill down through the documentation for that REST API endpoint as to what the NotificationRecipients can contain, it says that is can contain a value users which can be an array of UserDetails which is the type:

accountId

string

The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, 5b10ac8d82e05b22cc7d4ef5.

Max length: 128

So, in short, the only things that can be used as the recipient of the to part of the request for users are accountIDs, nothing else.

If you want to notify users other than the assignee, reporter, group etc, you're going to need to do a lookup of those users' accountIDs first, based on their email addresses, by using the find users endpoint , like this:

/rest/api/3/user/search?query=whatever@whatever

 Once you know all their accountIDs, then you can put that information into the ScriptRunner request's body.

 

To me, it sounds like you'd be better of using a group to contain all the users you want to notify, because a group can be a recipient. The next level of complexity up from that is to consider a custom notification scheme, but that is really using a sledge hammer on a brad.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

931 views 2 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you