0

I'm using the jira-python client to add a comment to an issue:

issue_id = 'SB-196'
comment = 'A Slack channel has been created for discussing this escalation: slack://channel?id={}&team={}'.format(new_channel_id, SLACK_TEAM_ID)
jira.comment(issue_id, comment)

The jira-python client is just a wrapper around the JIRA rest api. When I execute the code, I get a 404 error from JIRA which is recieving the following URL:

https://jira.mycompany.com/rest/api/2/issue/SB-196/comment/A%20Slack%20channel%20has%20been%20created%20for%20discussing%20this%20escalation:%0Aslack://channel?id=C123456&team=T123456

I'm assuming this is happening because it's trying to encode the Slack URL in the REST URL and getting confused. What's the correct way to encode the including URL so it doesn't get confused? Thanks!

darksideofthesun
  • 601
  • 2
  • 9
  • 19
  • 1
    According to the [docs](https://developer.atlassian.com/server/jira/platform/jira-rest-api-example-add-comment-8946422/) a POST is used to add a comment. The lib seems to do a get. But anyway you should try to URL encode the URI before adding it to the comment. – Klaus D. Mar 21 '18 at 01:41
  • Thanks! Your answer led me down the right path. – darksideofthesun Mar 21 '18 at 02:43

1 Answers1

0

Klaus D. led me down the right path. It turns out jira.comment() does a GET. In order to POST, you have to call jira.add_comment(). Once I did that, all worked fine (the client library automatically did the url encoding).

darksideofthesun
  • 601
  • 2
  • 9
  • 19