With Python 3, the body of POST requests is base64-encoded
See original GitHub issueAs 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: mail_host=example.com
+ body: !!binary |
+ bWFpbF9ob3N0PWV4YW1wbGUuY29t
headers:
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:
- Created 8 years ago
- Comments:15 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I fix my problem with the following code:
with open(file.path, “rb”) as pdf_file: encoded_string = base64.b64encode(pdf_file.read()) req_file = encoded_string.decode(‘utf-8’)
payload = { ‘req_file’ : req_file }
res = requests.post(url, data=json.dumps(payload), headers=headers)
Has work!!!
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! 🙏