Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Posting and mentioning a user via API

comment.png

If you have always wanted to post a comment via API but find it tedious to get the right format to @mention users on cloud well the wait is over or rather I should say, the way has been there all these while.

API has always been the key to automating certain aspect of the Atlassian suite whether you're using it for a small or large team. And with Atlassian moving towards a cloud first initiative, the cloud infrastructure will only get better over the years and I'm very excited about the future features that will spring up.

Okay let's go back to this article's title "posting and mentioning a user via API" sounds intriguing doesn't it, but how would you do it? The answer to that is going through the Atlassian docs and sourcing the right endpoint to use for adding comments. However processing the other part for mentioning a user will take its toll from other endpoints.

The example I'm showing below uses a package called jiraone which is a python package that can be download by using pip install jiraone. 

from jiraone import LOGIN, USER, comment

user = "email"
password = "token"
link = "https://yourinstance.atlassian.net"
LOGIN(user=user, password=password, url=link)

key = "COM-42"
name = "Prince Nyeche,Prince"
text = """
        <user> please can you help to check the docker environment? Ping <user> to help out.
        """
comment(key, method="post", text_block=text, placer="<user>", mention=USER.mention_user(name), event=True, visible="Users")

The name of users separated by comma, will be changed dynamically within the method with the mention keyword argument. Using the event=True argument enables the comment endpoint to actually post the text_block. placer="<user>" is a placeholder used to change the text string, it takes the names of the user and does a search and returns an acceptable format for mentioning users within the text string. visible="Users" enables you to use the comment visibility feature and restrict the comment to certain users, standard permission for that applies.End result is you have your comment posted on Jira.

 

0 comments

Comment

Log in or Sign up to comment
TAGS

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