Opened 12 years ago
Closed 12 years ago
#10785 closed defect (fixed)
json-rpc ticket.putAttachment results in 'unicode' object has no attribute 'data'
Reported by: | Marco Antonio Islas Cruz | Owned by: | osimons |
---|---|---|---|
Priority: | normal | Component: | XmlRpcPlugin |
Severity: | blocker | Keywords: | attachment |
Cc: | Olemis Lang | Trac Release: | 1.0 |
Description
I'm trying to use the json-rcp ticket.putAttachment but when using it the call returns with this:
{ u'error': { u'code': -32603, u'message': u"ServiceException details : 'unicode' object has no attribute 'data'", u'name': u'JSONRPCError'}, u'id': None, u'result': None}
The data I'm sending is this:
{ 'method': 'ticket.putAttachment', 'params': [1359, 'add.png', 'description data here', 'b64encoded_data', True]}
I've replaced the b64encoded data with a simple string for brevity.
This results in the call to be unusable.
Attachments (0)
Change History (8)
comment:1 Changed 12 years ago by
comment:3 follow-up: 5 Changed 12 years ago by
Keywords: | attachment added |
---|
Please mention Python version .
comment:4 Changed 12 years ago by
Summary: | json-rcp ticket.putAttachment results in 'unicode' object has no attribute 'data' → json-rpc ticket.putAttachment results in 'unicode' object has no attribute 'data' |
---|
comment:5 Changed 12 years ago by
comment:6 Changed 12 years ago by
Both wiki.putAttachment
and ticket.putAttachment
expects Binary
input:
yield (None, ((str, int, str, str, Binary, bool), (str, int, str, str, Binary)), self.putAttachment)
Why the wiki method reference documentation says...
string ticket.putAttachment(int ticket, string filename, string description, base64 data, boolean replace=True)
... I don't know. Documenting Binary
as base64
does not make it obvious that JSON-RPC really needs to use the class-hinting and post the data as {"__jsonclass__": ["binary", "<base64-encoded>"]}
.
Example from test shows how it is done, see for instance RpcWikiTestCase.test_attachments()
test in source:/xmlrpcplugin/trunk/tracrpc/tests/wiki.py
For XML-RPC this makes it even less obvious that the input required is actually xmlrpclib.Binary
type and not just the base64
string representation. Hmm, I'm sure the documentation used to say Binary
and not base64
. I wonder what changed and when...
Patch to fix documentation output most welcome ;-)
comment:7 Changed 12 years ago by
The JsonTestCase.test_binary()
test in source:/xmlrpcplugin/trunk/tracrpc/tests/json_rpc.py is a better example of how the JSON-RPC Binary
works.
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [12546]) XmlRpcPlugin: Use more general DateTime
and Binary
terms for method documentation, seeing that the underlying implementation may differ between protocols. Closes #10785.
The easiest way to solve this is to check if the
data
argument is a string if it is then use it as it comes, if not, then try to use then check if the data member is present, and if not, then we don't know how to treat this and raise an error.