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")
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
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 error
but if I do it towards a group, it sends the email without any problem with the same code
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.