MarketSquare / MarketSquare/robotframework-requests
Unable to post files with different content types and names
- Dominant language
- Python
- Stars
- 512
- Forks
- 283
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to post two files that corresponds to a part of one message with content-type application/xml and bodytext/plain. In postman I go to form data POST and give the key=metadata and value=file1 path (xml) and Key=0 and value=file2 path(txt) and it works fine and I'm able to insert. I'm supposed to use the same name for the files while inserting i.e. metadata and 0 respectively. This is what I have done through robot to imitate this behavior and it always returns a 500 Internal server error.
Insert Data
${auth}= Create List ${ID} ${SECRET}
${params}= Create Dictionary Key=${value} app=${apps}
${headers}= Create Dictionary Content-Type=multipart/form-data
Create Session mysession ${URL} auth=${auth} max_retries=10 backoff_factor=0.2
${metadata}= get binary file ${CURDIR}${/}insert.xml
${0}= get binary file ${CURDIR}${/}messageInsertion1.txt
${fileParts} create dictionary file1=${metadata} file2=${0}
${resp}= Post Request retain /messages params=${params} headers=${headers} files=${fileParts}
Response Code Should Be Success ${resp}
Contributor guide
Research direction
Start by reproducing the multipart request at the /messages endpoint using insert.xml and messageInsertion1.txt, comparing the Postman form-data fields metadata and 0 with the Robot Framework Requests Post Request call. Investigate how the files dictionary and Content-Type header are handled; done means the two parts retain their names and content types without a 500 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100