MarketSquare / robotframework-requests

Robot Framework keyword library wrapper for requests
http://marketsquare.github.io/robotframework-requests/
MIT License
487 stars 280 forks source link

Files param doesn't have to be a dictionary type #401

Closed patrikwilliam closed 1 day ago

patrikwilliam commented 1 month ago

https://github.com/MarketSquare/robotframework-requests/blob/233ff7cd2607344c08ee3649920a8083e36a835d/src/RequestsLibrary/RequestsKeywords.py#L52

It seems that a new change was introduced and now all the files used for POST have to be in the specific format.

However, this is not the case for all the scenarios. One can use Py requests to upload multiple files using list of tuples.

E. g. multiple_files = [ ('images', ('foo.png', open('foo.png', 'rb'), 'image/png')), ('images', ('bar.png', open('bar.png', 'rb'), 'image/png'))]

This no longer works and would be great to be fixed to be in align with Py requests library.

This causes the 'list' object has no attribute 'values' error. The workaround is to use the dictionary structure, but problem is if you need multiple files uploaded with same 'file' tag. Dictionary has to have unique key, having 4 times 'file' as the key is not possible.

lucagiove commented 4 weeks ago

when you talk about new change is in original requests library? could you provide more references to the changelog or documentation and the version you noticed this?

patrikwilliam commented 1 week ago

Hi @lucagiove thanks for a follow-up, it was broken by changes in commit 4de7ccd724ecedaedff85fc9815057aa92fc57e5: https://github.com/MarketSquare/robotframework-requests/commit/4de7ccd724ecedaedff85fc9815057aa92fc57e5#diff-1a10b1ae09ff166af95b8df428f6c301eb3ab7357d207b8ded10eb09e93926de on Apr 8 which should have fixed the closing of files, though it brought this regression up.

Thanks @vanhanit for having the PR ready, it works fine if that matters, maybe @lucagiove can give you a code review unless there are other proposals to have this fixed?