1. you only need to include post body contents if the watcher you're setting is different from the executing user.
2. This is a different issue from your original question but when you submit a create request the call will return the issuekey. You cant run post functions on create transition reliably unfortunately, use a listener instead and there will be an issue binding available.
Thank you for your question.
I can confirm that as Randy has said that to add a watcher with ScriptRunner for Jira Cloud that you will need to make a rest API call to the watchers API.
I can confirm that we have an example code snippet located here which can be run in the Script Console and shows how you can set the watcher on an Issue and that you will be able to take this example and modify it to create the post function that you require.
I can confirm that inside the post function that there is a variable called issue which comes in the binding of the script and you can get the issue key to pass into the rest call by calling issue.key.
Finally, I can advise that if you are creating your post function on the Create transition that the post function should be ordered as the last post function in the list of post functions, so that the issue is created before the post function code is executed.
If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.
Kristian thanks for this post https://bitbucket.org/snippets/Adaptavist/yAdX6X?_ga=2.267944206.120189328.1585505760-1987078914.1573938112
Since October I was trying to solve this problem.
This is my code to automatically add watchers from a certain JIRA group to a newly created Incident issue:
def issueKey = issue.key
def group = get('/rest/api/3/group/member')
def result = post('/rest/api/2/issue/' + issueKey + '/watchers')
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