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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,639,413
Community Members
 
Community Events
196
Community Groups

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.

 

1 comment

M Amine
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 09, 2021


Good information

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events