Hi all,
I’m trying to perform a multipart post request in robotframework. I’ve managed to get it working for the first four parameters (all plain text) however I’m having difficulties attaching a PDF file as the final fifth parameter. Here is the code I’m using so far:
Create a session for indexing api
Create Session indexing_session ${base_url} verify=True
Execute indexing api for mortagenumber "${mortgagenumber}"
[Arguments] ${type} ${description} ${sendtime} ${source} ${filename}
${filedata}= Get Binary File ${CURDIR}/../testdata/${filename}
${token}= Get new bearer token
${headers}= Create Dictionary Authorization=Bearer ${token}
${formdata}= Evaluate {'type': (None, '${type}', 'text/plain'), 'description': (None, '${description}', 'text/plain'),'sendTime': (None, '${sendtime}', 'text/plain'), 'source': (None, '${source}', 'text/plain'), 'files': ('${filename}', '${filedata}', 'application/pdf')}
${response}= POST On Session indexing_session /indexing/${mortgagenumber} headers=${headers} files=${formdata}
${json}= Set Variable ${response.json()}
Set Global Variable ${json}
The error atm is in the ‘Evaluate’ which cannot handle the contents of the converted pdf to binary. But also using the Get File For Streaming Upload method is resulting in an error when trying to handle the path in the Post on Session.
As a reference a screenshot of SOAPUI where i’ve managed to create a working request including PDF.
Many thanks in advance,
Peter