ScriptRunner Jira Cloud - Send Emails a Specific User

Marcelo Ulloa March 6, 2024

Good afternoon community, I have a question. When sending emails with ScriptRunner, I can use groups, responsible parties, informants, etc. However, if I try to send it to a specific user's email, I get an error. Is this restricted in some way, or am I doing something wrong?

 

Is there a way to send the email to a user in my organization's directory? I've tried using the user's email, name, and ID, but all attempts indicate that no specific user is specified to send the email.

 

//Script that works

def issueKey = "SCRIP-258"
def nombreGrupo = 'Test Correo Script'

def resp = post("/rest/api/2/issue/${issueKey}/notify")
.header("Content-Type", "application/json")
.body([
subject: "Tiene asignada ${issueKey} ",
textBody: "Body",
htmlBody: "<p>Test</p>",
to: [
groups: [
[
name: "${nombreGrupo}" 
]
]
]
])
.asString()

def bol = true
logger.info("Correo enviado")

 

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 7, 2024

Hi Marcello,

 

I can confirm the notify API Atlassian provide can only notify Jira users and it cannot be used to send external emails.

We have an example of using this API in our docs site here, which you may find useful.

I hope this information helps.

Regards,

Kristian

Marcelo Ulloa March 7, 2024

Thank you for your response, when trying to send the email to myself, with the name that appears in my organization's directory

 

def issueKey = "SCRIP-258"


def resp = post("/rest/api/2/issue/${issueKey}/notify")
.header("Content-Type", "application/json")
.body([
subject: "Tiene asignada como agente la Issue - ${issueKey}",
textBody: "Body",
htmlBody: "test",
to: [
users: [
[
name: 'Marcelo Nicolas Ulloa Fernandez'
]
]
]
])
.asString()

def bol = true 

 

It returns this errorimage.png

but if I do it towards a group, it sends the email without any problem with the same code

image.png

 

So I cannot send an email to a specific user within the Atlassian directory of my organization, since what cannot be done is send to a user external to the organization.

If you can help me, to see what I'm doing wrong.

 

Thanks 

 

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2024

Hi Marcello,

I can confirm, as mentioned in the example above the notify API does not allow to you send a notification to your own user, so it will not work sending a notification to yourself.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events