Change visibility comment via api

Hi, im trying to modify the visibility restriction of a comment to no restriction.
First of all i add a comment using this:

def body
//def roleType = "Nivel 1"
def commentBody = "test"
def roleType = null
def issueKey = "<IssueKey>"
if(roleType != null){

def tempCommentBody = "[Internal] " + commentBody
body = [
"visibility": [
"type": "role",
"value": roleType
],
"body": tempCommentBody
]

logger.info "Create comment BODY:" + body

} else {
logger.info "Visibilidad public"

def tempCommentBody = "[Public] " + commentBody
body = ["body": tempCommentBody]
logger.info "Create comment BODY:" + body

}

def response2 = post("/rest/api/2/issue/${issueKey}/comment")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.body(body)
.asJson()

after the creation you can save the comment id using:

def commentId = response2.body.array[0].id.toString()```

and after that you can modify the visibility from null to "nivel 1"using:

def response = put("/rest/api/2/issue/${issueKey}/comment/${commentId }")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.body(body)
.asJson()

That is working, but if i try to do the reverse, going from “nivel 1” to nothing is not working, in this case u just need to uncomment the line roletype to the other one and that update the comment.

That was working before but not anymore. I’m missing something?

Thanks!

My guess is that you will need to change the visibility to type=group and value=jira-users to make it publicly available.

Hi, thanks but is not what i need, because my client doesn’t have that jira group for all the users, all i want is no restriction visibility, no restrict it to a group.

Thanks anyways

my client doesn’t have that jira group for all the users

I’m not sure if this is possible in Jira Cloud, because I think site access is governed via groups. This is also why my guess is that visibility always defaults to a specific group in the first place, even for public. But again, this is all assumption.

it was possible few days a go, so yes

In case someone needs a more concrete answer, I would recommend Remie’s approach of using type=group but you might have to change your global jira settings. I detailed how to do that here

Then you can set to type=group and value=jira-users. You can see the possible options for value under user management > groups. You should see a list of groups that kinda look like the ff:

  • administrators
  • jira-administrators
  • jira-software-users
  • site-admins
1 Like