Send noticification to a user using Rest Api shows an error

Maro Hamamjyan March 27, 2018

Hello, 

I try to send notification to u user and for that I use this https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/?&_ga=2.151790077.57291028.1522048569-1716142108.1508839203#api/2/issue-notify

  documentation---> Notify. I have changes the request in this way:

{
    "subject": "TEST",
    "textBody": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
    "htmlBody": "Lorem ipsum <strong>dolor</strong> sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
    "to": {
       
         "users": [
            {
                "name": "Maro Hamamjyan",
                "active": false
            }
        ]
                
    }
       
}

 

which bring me this error:

{
    "errorMessages": [
        "Issue Does Not Exist"
    ],
    "errors": {}
}

 

I understand that I do not mention any ID or key in the request and thought maybe I must have this blog too:

"permissions": [
            {
                "id": "10",
                "key": "BROWSE"
            }
        ]

but am not sure that I am right and how can I get the ID or Key.

The error number is 404 Not Found

 

Please advice something! 

Thanks in advance

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2018

Hi Maro,

The REST endpoint you cited: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/reindex-getReindexInfo

Does not have any means to send notifications.   This endpoint is designed only to start/stop/get info in regards to indexing in Jira.  If you look at the example json, and the schema json listed on that page you can see all the json parameters that are viable for that endpoint.   None of these are notification parameters in Jira.

Not all rest endpoints in Jira will have the ability to send notifications, and those that do, typically do not have the means to define who the recipient of these notifications will be in the json.   Primarily when notifications are sent by Jira, it does so via the notification scheme applied to that project.

Maro Hamamjyan March 28, 2018

Hi  Andrew,

Thanks for your reply! I am sorry for the wrong link, I wanted to paste this one: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/?_ga=2.144271985.57291028.1522048569-1716142108.1508839203#api/2/issue-notify

I think with the help of this it is possible to send notification, if the error that I described above is solved, what do you think?

 

Thanks in advance

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 29, 2018

ah, ok.  That makes more sense.   Yes, you could use that REST endpoint to send a notification to a user.  But this will be in regards to a specific Issue in Jira.  In this case, you can specify a user, but the example shows that this is "active" : "false".  In this case, if you want to send to a user that is not in the reporter, watcher, voters, or assignee roles, then you can use that users option.  But, to the best of my knowledge, Jira can't send notifications about issues to users in Jira that are not listed as being active.

So if you're using that endpoint and you do a Post that specifies the issue key or the issue id, then this should work.  But in your case, I think you will need to tweak this to be:

"to": {
       
         "users": [
            {
                "name": "Maro Hamamjyan",
                "active": true
            }
        ]
                
    }

And your Jira instance will have to have a user named "Maro Hamamjyan" to be able to send that user an email notification of this issue.

Try this.  If this doesn't work as expected, let me know more about what method you are using to make this REST call.  Are you using curl to post this call?  Or some other REST API tool like Postman?

Maro Hamamjyan March 29, 2018

Hi Andrew,

Thank you very much for detailed information, I will be attentive to follow the rules every time when use REST API. I was trying to make it work in Postman then to continue working with C#. However the problem is solved, I didn't notice that in URI (POST /rest/api/2/issue/{issueIdOrKey}/notify) I need to specify the issueIdOrKey ( I am very new in REST API), so that was the problem.

Thank you one more time.

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2018

Happy to help out.

Suggest an answer

Log in or Sign up to answer