Vincenzo
(Vincenzo Ferraro)
1
Good afternoon,
I’m continuing with my PHP project with JSON-RPC calls to the Tryton server.
I have a problem: I can not insert attachments.
I’m using the model.ir.attachment.create method.
Which format should I convert the file to?
What does the bytearray method do?
Thank you
albert
(Albert Cervera i Areny)
2
I guess you should use base64 for the binary content
ced
(Cédric Krier)
3
Indeed the JSON format for binary value is an object like {'__class__': 'bytes', 'base64': value}
where value is the content encoded in base64.
Vincenzo
(Vincenzo Ferraro)
4
I can not make it work…
Analyzing the data exchanged by the client in verbose mode I send this:
INFO:tryton.rpc:model.ir.attachment.create([{u'data': bytearray(b'VALUE'), u'resource': 'stock.shipment.out.return,1', u'name': u'FB_IMG_1503910564025.jpg', u'type': u'data'}], PREF)
I should enter
{'__class__': 'bytes', 'base64': value}
instead of
bytearray(b'VALUE')
?
ced
(Cédric Krier)
5
Yes bytearray is the Python object which does not exist in PHP.
1 Like
system
(system)
Closed
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.