Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

With Python 3, the body of POST requests is base64-encoded

See original GitHub issue

As a consequence of commit 09b7ccf (more precisely, of the conversion in the request body setter), the body of the POST requests are unreadable in the tape file:

--- tape.yaml
+++ tape.yaml
@@ -41,8 +41,7 @@ interactions:
       content-type: [application/json; charset=utf-8]
     status: {code: 200, message: OK}
 - request:
-    body:
+    body: !!binary |
+      bWFpbF9ob3N0PWV4YW1wbGUuY29t
       accept-encoding: ['gzip, deflate']
       content-type: [application/x-www-form-urlencoded]

It makes it much harder to diff changes between tapes committed in a VCS, and to identify what each request is coming from in the code.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

danilosoarescommented, Apr 20, 2018

I fix my problem with the following code:

with open(file.path, “rb”) as pdf_file: encoded_string = base64.b64encode( req_file = encoded_string.decode(‘utf-8’)

payload = { ‘req_file’ : req_file }

res =, data=json.dumps(payload), headers=headers)

Has work!!!

neozenithcommented, Jan 5, 2020

A lot of changes have happened to VCRpy since this ticket was opened. As this ticket has become stale and we have a lot of old tickets that need to be groomed, I’m closing this for now to make it easier to see what is still relevant.

However if it is still needed, please feel free to re-open or create a new ticket.

Thanks! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

base64 — Base16, Base32, Base64, Base85 Data Encodings ...
Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines ( b'\n' )...
Read more >
HTTP PUT with base64 encoded attachment using requests
I see the header in the HTTP Dump, but I am still getting back HTTP 415 Unsupported Media Type . UPDATE 3. It...
Read more >
Encoding and Decoding Base64 Strings in Python
First we convert the Base64 strings into unencoded data bytes followed by conversion into bytes-like object into a string. The below example ...
Read more >
Base64 Encoding and Decoding Using Python - Code
The Base64 encoded data ends up being longer than the original data, so that as mentioned above, for every 3 bytes of binary...
Read more >
Video Calling RESTful authentication - Agora Documentation
You need to generate a Base64-encoded credential with the Customer ID and ... basic HTTP authentication and send a request with the Server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found