Your function is not returning a string, but a file-like object.
If it were a string indeed, result.read()
would raise an Error, because strings don't have a method read
.
Once read, xmlPayload
is a string which you can then pass to ET.fromstring
.