Modify

Opened 9 years ago

Closed 7 years ago

#12438 closed defect (worksforme)

Encoding Error: Not well formed for server.ticket.putAttachment()

Reported by: anonymous Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

The error: <Fault -32700: 'not well-formed (invalid token): line 15, column 15'> occurs when putAttachment() is used.

# Read file and write to Trac
ticketNum = 97
imageFile = "Tick_97_TracAttach_0_.png"
with open(imageFile, "rb") as image:
    data = image.read()
fileName = p.ticket.putAttachment(ticketNum, imageFile, "Image from D2D", data, True)

There are no problems with the getAttachment() function

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by osimons

You can't put raw binary data into an XML stream. It is bound to cause errors when parsing.

The spec says that the data is Binary, and in this case that means xmlrpclib.Binary type:

from xmlrpclib import Binary
...
    data = Binary(image.read())
...

comment:2 Changed 7 years ago by Ryan J Ollos

Resolution: worksforme
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.