Problem on add Attachments (PHP Project)

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

I guess you should use base64 for the binary content

Indeed the JSON format for binary value is an object like {'__class__': 'bytes', 'base64': value} where value is the content encoded in base64.

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')?

Yes bytearray is the Python object which does not exist in PHP.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.