robotframework-requests: POST request fails when both data and files are provided
When 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)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (17 by maintainers)
@volinthius thank you all your observations, I am little busy with other tasks, Pull requests are much appreciated!!