On each recursive call of make_request, json.dumps is called on body. This results in a string that is already json encoded being re-encoded. Everytime this happens back slashes are escaped again creating invalid requests:
(try: json.dumps(json.dumps(json.dumps('\\'))) for an example of whats going on).
Requests has specific support for json encoded body by using json= instead of data= when making a post request. This avoids the need to encode and I think is the easiest way to solve this issue.
On each recursive call of
make_request
, json.dumps is called on body. This results in a string that is already json encoded being re-encoded. Everytime this happens back slashes are escaped again creating invalid requests: (try:json.dumps(json.dumps(json.dumps('\\')))
for an example of whats going on).Requests has specific support for json encoded body by using json= instead of data= when making a post request. This avoids the need to encode and I think is the easiest way to solve this issue.