Bug 1414063
| Summary: | Cannot update bug with a comment | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Community] Bugzilla | Reporter: | Martin Kosek <mkosek> | ||||
| Component: | WebService | Assignee: | PnT DevOps Devs <hss-ied-bugs> | ||||
| Status: | CLOSED NOTABUG | QA Contact: | tools-bugs <tools-bugs> | ||||
| Severity: | high | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 5.0 | CC: | dsoman, huiwang, jfearn, kumarjyoti7008, qgong, skuznets, yijli | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2017-02-15 23:50:16 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
|
Description
Martin Kosek
2017-01-17 16:08:48 UTC
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. What was the actual issue here and what, specifically, is the fix? Minimal reproducer:
$ curl -X PUT --data '{"status":"POST"}' "https://bugzilla.redhat.com/rest/bug/1705657?api_key=$KEY"
{"documentation":"https://bugzilla.redhat.com/docs/en/html/api/index.html","error":true,"code":100500,"message":"Can't use string (\"{\"ids\":[1705657],\"status\":\"POST\"\") as a HASH ref while \"strict refs\" in use at /var/www/html/bugzilla/Bugzilla/Bug.pm line 3120.\n"}
Err, had the wrong output, but the output just mirrors whatever I PUT:
{"documentation":"https://bugzilla.redhat.com/docs/en/html/api/index.html","error":true,"code":100500,"message":"Can't use string (\"{\"status\":\"POST\"}\") as a HASH ref while \"strict refs\" in use at /var/www/html/bugzilla/Bugzilla/Bug.pm line 3120.\n"}
Ah, looks like the server expects the header: "Content-Type: application/json" This should be updated in the documentation: https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug . |