MarketSquare / robotframework-requests

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

How to download multiple files in local system using POST API request in robot framework rather than in binary form data ? #388

Closed dhingrachirag closed 3 months ago

dhingrachirag commented 8 months ago

I struck in one scenario in which i need to download multiple files in local repository using POST API request in robot framework.

I tried below code but not able to resolve the issue.

${headers}=  Create Dictionary   Accept=${aster}    Host=api.demosite.com    Connection=keep-alive    Content-Type=${accept}    Accept-Encoding=gzip, deflate, br    User-Agent=${user_agent}
 ${response}=    ExtendedHTTPLibrary.POST On Session    Global    ${resultfiles}    headers=${headers}    json=${demo_body}    stream=${False}
 log    ${response.content}    level=TRACE
 copy files    ${response}    ${EXECDIR}/Logs

When i used above code it gives me some binary stream which i am not able to understand.Something like below:

�9BBi��HI�d(������%E�i� ��M��<�^,;��������:��\�{|�}�k���^��{�<��G�#�����7��!�ou����u��7Q��_j�&gl���Sc�I� P�󸤋�é�lT� �5��1{w�c.>�v�����=����mok�A��r����0�����I��y���9�8� <��1���Lʥ�����q�N��1x0�89�CF���1�'����G8I�q���.G���<�$�Q���͓y�~���G�S��ţ�G���O�[m�(

In postman we have that option to SEND and DOWNLOAD files and through that i am able to download multiple files in zip folder in my local system.

Screenshot 2024-03-05 at 11 51 16 AM

My questions are :

  1. How to download multiple files in local system or directory using robot framework through POST API request rather than binary stream ?
  2. How to achieve task through robot code which postman UI is providing through SEND and DOWNLOAD option ?

Below scenario is expected :

  1. Fire POST API request
  2. DOWNLOAD Files through response of POST API
  3. STORE files in local directory.
lucagiove commented 3 months ago

From the description seems you're using a http extended library not this library. By the way I don't think copy file accept a file content but only a file path, you better have to look at create file keyword. Anyway this is not really related with this library.