Add attachment to invoice

Add attachment to invoice

Hi,
I am currently trying to add attachment to invoce and no luck
using java POST query
and post parameters
authtoken=zzz&invoice_id=xxx&can_send_in_mail=false&attachment=yyy
where
xxx - an invoice id
yyy - file content
zzz - authtoken
Result
I assume the file should be loaded to some server first, if so then what API should be used to upload file?
Could someone please help me? 
Thank you