POST request fails when both data and files are provided
See original GitHub issueWhen making a POST request with both data
and files
keyword arguments the request fails with:
$ pybot test1.txt
==============================================================================
Test1
==============================================================================
Test One | FAIL |
ValueError: Data must not be a string.
------------------------------------------------------------------------------
Test1 | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Requests Python library makes a check against data
(when using files
) in requests/models.py
in function _encode_files
:
if (not files):
raise ValueError("Files must be provided.")
elif isinstance(data, basestring):
raise ValueError("Data must not be a string.")
Here is test case to reproduce the error:
*Settings*
Library RequestsLibrary
Library OperatingSystem
*Test Case*
Test One
Create Session Foo http://localhost
${data}= Create Dictionary foo=bar
Create File foobar content=foobar
${files}= Evaluate open('foobar')
Post Request Foo /foo data=${data} files=${files}
I’m using the following library versions (from pip list
):
- requests (2.11.1)
- robotframework (3.0)
- robotframework-requests (0.4.5)
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (17 by maintainers)
Top Results From Across the Web
POST request fails when sending too much data
The file data is stored as a string. var fd = new FormData(); fd.append('fileString', file.attachmentString); fd.append( ...
Read more >Error when POST file multipart/form-data · Issue #505 - GitHub
Hi, I got an error every time when trying to POST data to the API. Request: changeUserAvatar(authParam, file) { let formData = new...
Read more >Solved: Post File via HTTP - Power Platform Community
Solved: I can't get this to work in flow. I get bad request. Below is the 400 status code and the header and...
Read more >$_FILES - Manual - PHP
If $_FILES is empty, even when uploading, try adding enctype="multipart/form-data" to the form tag and make sure you have file uploads turned on....
Read more >Upload file data | Google Drive
Note: In the Drive API documentation, media refers to all available files with MIME ... Create a POST request to the method's /upload...
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
@volinthius thank you all your observations, I am little busy with other tasks, Pull requests are much appreciated!!
Ok it seems to work. Maybe, in the first test, I just messed up something. Thank you for your help 😃