Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-1261

Comment return from REST API does not include Visibility for Service Desk Project

    • Icon: Suggestion Suggestion
    • Resolution: Answered
    • None
    • API and Integrations
    • None
    • We collect Jira Service Desk feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      NOTE: This suggestion is for JIRA Service Desk Server. Using JIRA Service Desk Cloud? See the corresponding suggestion.

      Problem statement

      Internal comment and customer facing comment does not get separated when retrieving comment data via REST API

      Steps to reproduce

      1. Install Service Desk and use DESK project
      2. On DESK-1 issue, add a comment to the customer, and comment for Internal
      3. GET request to http://localhost:8080/rest/api/latest/issue/DESK-1/comment
      4. The following are the results on my testing
        {"startAt":0,"maxResults":2,"total":2,"comments":[{"self":"http://localhost:8080/rest/api/2/issue/10000/comment/10000","id":"10000","author":{"self":"http://localhost:8080/rest/api/2/user?username=admin","name":"admin","emailAddress":"admin@email","avatarUrls":{"48x48":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=48","24x24":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=24","16x16":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=16","32x32":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=32"},"displayName":"admin AWESOME","active":true},"body":"Testing to customer","updateAuthor":{"self":"http://localhost:8080/rest/api/2/user?username=admin","name":"admin","emailAddress":"admin@email","avatarUrls":{"48x48":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=48","24x24":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=24","16x16":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=16","32x32":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=32"},"displayName":"admin AWESOME","active":true},"created":"2014-12-12T22:12:58.263+0800","updated":"2014-12-12T22:12:58.263+0800"},{"self":"http://localhost:8080/rest/api/2/issue/10000/comment/10001","id":"10001","author":{"self":"http://localhost:8080/rest/api/2/user?username=admin","name":"admin","emailAddress":"admin@email","avatarUrls":{"48x48":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=48","24x24":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=24","16x16":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=16","32x32":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=32"},"displayName":"admin AWESOME","active":true},"body":"Testing internal","updateAuthor":{"self":"http://localhost:8080/rest/api/2/user?username=admin","name":"admin","emailAddress":"admin@email","avatarUrls":{"48x48":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=48","24x24":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=24","16x16":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=16","32x32":"http://www.gravatar.com/avatar/2edb867fbee6e0cb054975ff1e4bcc8d?d=mm&s=32"},"displayName":"admin AWESOME","active":true},"created":"2014-12-12T22:13:09.053+0800","updated":"2014-12-12T22:13:09.053+0800"}]}

      Expected behaviour

      The Internal comment for Service Desk should include visibility attribute similar in its JSON data to JIRA's in the following

                  "visibility": {
                      "type": "role",
                      "value": "Administrators"
                  }

      Workaround (Thanks to Jaroslaw in his comment)

      • Add expand=properties to this REST URI
      • For example
        http://localhost:8080/rest/api/latest/issue/DESK-1/comment?expand=properties

            [JSDSERVER-1261] Comment return from REST API does not include Visibility for Service Desk Project

            Thank you for the this Discussion

            jaya devan added a comment - Thank you for the this Discussion

            Hey thanks for posting this update , just what i needed.

            Haresh Devaliya added a comment - Hey thanks for posting this update , just what i needed.

            This information is available through the JIRA REST API, with the expand=properties parameter, as described.

            Matthew McMahon (Inactive) added a comment - This information is available through the JIRA REST API, with the expand=properties parameter, as described.

            Fernando Boucquez (PPL) added a comment - - edited

            Get comment property rest method (/rest/api/2/comment/YOUR_COMMENT_ID/properties/sd.public.comment) doesn't work for AC addons as it hasn't been whitelisted.

            https://ecosystem.atlassian.net/browse/ACJIRA-306

            Fernando Boucquez (PPL) added a comment - - edited Get comment property rest method (/rest/api/2/comment/YOUR_COMMENT_ID/properties/sd.public.comment) doesn't work for AC addons as it hasn't been whitelisted. https://ecosystem.atlassian.net/browse/ACJIRA-306

            Hey thanks for posting this update, just what I needed!

            Andy Brook added a comment - Hey thanks for posting this update, just what I needed!

            Answering my own question:

            Is there any way to fetch all comments with the sd.public.comment property with use of just one REST call?

            Yes. Simply add expand=properties to this REST URI. This flag is undocumented.

            Jarosław Heba added a comment - Answering my own question: Is there any way to fetch all comments with the sd.public.comment property with use of just one REST call? Yes. Simply add expand=properties to this REST URI . This flag is undocumented.

            Hi Zulfadli Noor Sazali,

            After some analysis of database tables of service desk and data stored in them, I figured out that service desk uses comment properties to mark whether a comment is internal or not. See records in entity_property db table:

            internal comment
            mysql> SELECT * FROM entity_property WHERE ENTITY_ID = YOUR_COMMENT_ID;
            +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+
            | ID    | ENTITY_NAME         | ENTITY_ID | PROPERTY_KEY      | CREATED             | UPDATED             | json_value        |
            +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+
            | 10287 | CommentProperty     |    101062 | sd.public.comment | 2014-12-12 15:49:07 | 2014-12-12 15:49:07 | {"internal":true} |
            | 10288 | sd.comment.property |    101062 | sd.public.comment | 2014-12-12 15:49:07 | 2014-12-12 15:49:07 | {"internal":true} |
            +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+
            2 rows in set (0.00 sec)
            

            This property can be retrieved with use of this REST URI (i.e. /rest/api/2/comment/YOUR_COMMENT_ID/properties/sd.public.comment ).

            So far so good, but… using that would mean that if I want to display only public comments, I have to loop through all comments in an issue and make one REST call for each of the comments in order to check value of the sd.public.comment property.

            How would it scale?
            Is there any way to fetch all comments with the sd.public.comment property with use of just one REST call?

            Jarosław Heba added a comment - Hi Zulfadli Noor Sazali, After some analysis of database tables of service desk and data stored in them, I figured out that service desk uses comment properties to mark whether a comment is internal or not. See records in entity_property db table: internal comment mysql> SELECT * FROM entity_property WHERE ENTITY_ID = YOUR_COMMENT_ID; +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+ | ID | ENTITY_NAME | ENTITY_ID | PROPERTY_KEY | CREATED | UPDATED | json_value | +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+ | 10287 | CommentProperty | 101062 | sd. public .comment | 2014-12-12 15:49:07 | 2014-12-12 15:49:07 | { "internal" : true } | | 10288 | sd.comment.property | 101062 | sd. public .comment | 2014-12-12 15:49:07 | 2014-12-12 15:49:07 | { "internal" : true } | +-------+---------------------+-----------+-------------------+---------------------+---------------------+-------------------+ 2 rows in set (0.00 sec) This property can be retrieved with use of this REST URI (i.e. /rest/api/2/comment/YOUR_COMMENT_ID/properties/sd.public.comment ). So far so good, but… using that would mean that if I want to display only public comments, I have to loop through all comments in an issue and make one REST call for each of the comments in order to check value of the sd.public.comment property. How would it scale? Is there any way to fetch all comments with the sd.public.comment property with use of just one REST call?

              Unassigned Unassigned
              znoorsazali Zul NS [Atlassian]
              Votes:
              3 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: