Testing REST API using Robot Framework. Can't upload a CSV File and data via POST request

342 views
Skip to first unread message

Jyoti Kaloya

unread,
Sep 26, 2017, 11:54:24 AM9/26/17
to robotframe...@googlegroups.com

I am very new to testing / developing. I am currently testing a REST API. In Postman I send a POST request by specifying parameters and uploading a .csv file using form-data in the body. My request always succeeds. However, when I try to translate this into Robot Framework (using the Requests Library), I get a 400 Error.


I am posting my code below.


I have been trying to resolve this issue for a while now. Any help in the right direction would be much appreciated!



Create Session  Alias  http://{{Host}}{{Port}}


${data}=  Create Dictionary   inputFileTypeId=1  dataType=csv


Set to Dictionary   ${data}


${file_data}  Get Binary File  ${CURDIR}${/}File1.csv


${files}  Create Dictionary  file  ${file_data}


Log  ${files}


Log  ${data}


${resp}  RequestsLibrary.Post Request  Alias  /URI  files=${files}  data=${data}


Log  ${resp}


Should Be Equal As Strings  ${resp.status_code}  200


Jyoti Kaloya

unread,
Sep 26, 2017, 2:24:20 PM9/26/17
to robotframework-users
I was able to resolve the issue. Please see the correction in the comments here.
Reply all
Reply to author
Forward
0 new messages