Thanks. That sorts out the use of "\n". It doesn't of course sort out why "[[BR]]" only works a bit sometimes, but as I've got "\n" working I don't care about "[[BR]]" any more.
-----Original Message----- From: trac-users@googlegroups.com [mailto:trac-users@googlegroups.com] On Behalf Of Jun Omae Sent: 01 September 2017 17:16 To: trac-users@googlegroups.com Subject: Re: [Trac] Newlines in comments? On Wed, Aug 30, 2017 at 5:09 PM, Tim Ward <t...@brettward.co.uk> wrote: > data = '{{ "params": [ {}, "{}", {{ "action": "leave" }}, true ], > "method": "ticket.update" }}' > > r = requests.post( url, data=data.format( ticketId, comment ), > headers=headers, auth=auth ) > > (Python) - how do I usefully include a line break in the content of > the comment string variable? Your generated json string is incorrect. Your request with the incorrect json leads error response from XMLRPC plugin. >>> data = '{{ "params": [ {}, "{}", {{ "action": "leave" }}, true ], "method": >>> "ticket.update" }}' >> print(data.format(42, 'line 1\nline 2\n')) { "params": [ 42, "line 1 line 2 ", { "action": "leave" }, true ], "method": "ticket.update" } You should use json.dumps() rather than directly generating json string if you cannot implement it. >>> import json >>> ticketId = 42 >>> comment = 'line 1\nline 2\n' >>> data = {'params': [ticketId, comment, {'action': 'leave'}, True], >>> 'method': 'ticket.update'} >>> print(json.dumps(data)) {"params": [42, "line 1\nline 2\n", {"action": "leave"}, true], "method": "ticket.update"} -- Jun Omae <jun6...@gmail.com> (大前 潤) -- You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/g8PAErIOgLQ/unsubscribe. To unsubscribe from this group and all its topics, send an email to trac-users+unsubscr...@googlegroups.com. To post to this group, send email to trac-users@googlegroups.com. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscr...@googlegroups.com. To post to this group, send email to trac-users@googlegroups.com. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.