Red Hat Bugzilla – Bug 1414063
Cannot update bug with a comment
Last modified: 2017-02-16 02:24:01 EST
Description of problem: I cannot update Bugzilla with a comment entered: $ python ... >>> r = s.put('https://beta.bugzilla.redhat.com/bugzilla/rest/bug/1285012', data={'cf_devel_whiteboard': u'test2', 'comment':{u'body': u'test comment2', 'is_private': False}, 'Bugzilla_token':u'xxxxxxxxx'}) >>> print r.json() {u'code': 100500, u'message': u'Not a HASH reference at /var/www/html/bugzilla/Bugzilla/WebService/Bug.pm line 746.\n', u'documentation': u'https://beta.bugzilla.redhat.com/bugzilla/docs/en/html/api/index.html', u'error': True} When I do not have comment hash there, update works: >>> r = s.put('https://beta.bugzilla.redhat.com/bugzilla/rest/bug/1285012', data={'cf_devel_whiteboard': u'test2', 'Bugzilla_token':u'xxxxxxxxx'}) >>> print r.json() {u'bugs': [{u'alias': [], u'changes': {u'cf_devel_whiteboard': {u'removed': u'', u'added': u'test2'}}, u'id': 1285012, u'last_change_time': u'2017-01-17T16:00:39Z'}]} This is the documentation I used: https://beta.bugzilla.redhat.com/bugzilla/docs/en/html/api/core/v1/bug.html#update-bug Version-Release number of selected component (if applicable): 5.0.3.rh18 How reproducible: Always Steps to Reproduce: 1. Run example Python above 2. 3. Actual results: Command always fails Expected results: Update with a comment succeeds! Additional info:
BTW, I think there is some systematic error either on my or Bugzilla side, I receive similar error with Flag update: >>> r = s.put('https://beta.bugzilla.redhat.com/bugzilla/rest/bug/1346342', data={'flags': [{'status': '+', 'name': 'devel_ack'}], 'Bugzilla_token': u'xxxxxxxxxx'}) >>> print r.json() {u'code': 100500, u'message': u'Can\'t use string ("status") as a HASH ref while "strict refs" in use at /var/www/html/bugzilla/Bugzilla/WebService/Util.pm line 49.\n', u'documentation': u'https://beta.bugzilla.redhat.com/bugzilla/docs/en/html/api/index.html', u'error': True}
I can't duplicate this using perl, if the issue is still occurring please provide a complete example for testing. https://beta-bugzilla.redhat.com/show_bug.cgi?id=1285012#c12 https://beta-bugzilla.redhat.com/show_bug.cgi?id=1285012#c13 https://beta-bugzilla.redhat.com/show_bug.cgi?id=1285012#c14
Created attachment 1250634 [details] Reproducer Let me attach full Python example that can be used for testing.
You need to s/data/json/ in your script. Also, API_KEYs really do make scripting easier :) $ cat rest-test.py #!/usr/bin/python2 import sys APIKEY='SECRET' import requests s = requests.Session() r = s.put('https://beta-bugzilla.redhat.com/rest/bug/1346342', json={'comment':{u'body': u'test comment', 'is_private': False}, 'Bugzilla_api_key': APIKEY}) print "Result code:", r.status_code print "Result text", r.text $ ./rest-test.py Result code: 200 Result text {"bugs":[{"changes":{},"id":1346342,"last_change_time":"2017-02-15T23:44:03Z","alias":[]}]}
Thanks Jeff! Your advise worked! Now back to porting our tool to the new (nice) Bugzilla REST API.
posted on 2018-02-07 15:42 feifeiyuan 阅读(267) 评论(0) 收藏 举报