Adding a comment - YouTrack Python REST Library
I have problem using the Python Client API youtrack library to programmatically add the comment to an existing issue. I was not able to find the right method in the API nor use the executeCommand() successfully so I wrote my one method which given the Connection object runs the POST request to add the comment:
Please sign in to leave a comment.
issue_id = "OP-1093"
response, content = youtrack_conn._req('POST', '/issue/%s/execute?%s' % (issue_id, urllib.urlencode(params)))
The problem is that if the comment to be added is just a little larger, not more than 1KB I get the following error and the comment is not added successfully.
413: FULL head
If I shorten the comment it is added successfully.
I had the same error message earlier when I was using the createIssue() method in the older YouTrack API and when I tried to add the description string bigger than ~1 KB. Once I checked out the most recent code from GIT the createIssue() method works fine with small or large description field.
I kindly ask you to try this via Apply command method first. Command to add a comment to an issue is:
Thank you.
def executeCommand(self, issueId, command, comment=None, group=None, run_as=None):
if isinstance(command, unicode):
command = command.encode('utf-8')
params = {'command': command}
if comment is not None:
params['comment'] = comment
if group is not None:
params['group'] = group
if run_as is not None:
params['runAs'] = run_as
for p in params:
if isinstance(params[p], unicode):
params[p] = params[p].encode('utf-8')
response, content = self._req('POST', '/issue/' + issueId + "/execute?" +
urllib.urlencode(params), body='')
return "Command executed"
Which command should be specified when adding the comment?
comment="Some comment"
connObj.executeCommand("OP-1093", "comment", comment)
It works well for very short comments, but trying to add the comment of size equal to few 1000 characters (when url encoded) gives the same error as before. How can I remove this limit?
Error message:
0A+%3C%2FTR%3E%0A%3C%2FTABLE%3E%7Bhtml%7D&command=comment]: 413: FULL head
Thanks!