[Twisted-Python] treq POST abborting with: err: ('Could not adapt', '{"....", "..."} <InterfaceClass twisted.web.iweb.IBodyProducer>)

Tristan Seligmann mithrandi at mithrandi.net
Fri Jan 6 16:36:24 MST 2017


On Fri, 6 Jan 2017 at 21:21 steven meiers <commercials24 at yahoo.de> wrote:

> glyph (without seeing the the code or backtrace) suggested that:
> "I think the issue might be that it doesn't support bytes() on py3,
> it's registered against str() or something"
>

Actually, the problem is the reverse of this; only bytes is supported, but
you're passing str (unicode) in.


>         somepage = yield treq.post(target_url, json.dumps({hmac: key,
> "username": username, 'pw':'', 'gender':'m', 'aaaa':''}),
>

json.dumps returns str (ie. unicode) on py3; throwing in a .encode('utf-8')
here is probably what you want.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170106/8e155e48/attachment-0002.html>


More information about the Twisted-Python mailing list