I am struggling to get my Robot Framework code working. I am trying to create a post request to my End point Called finance/uploadPayments .
This endpoint takes in three key values:
below is my robot frame keywork:
Process payment
Create Session Alias ${API_URL}
${file_data} Get Binary File ../tests/data/positive/rca_load_77773_2021-01-10_0953.csv
${data}= Create Dictionary username=NicoleS delimiter=pipe
${header}= create dictionary Accept=text/plain Content-Type=application/x-www-form-urlencoded
Set to Dictionary ${data}
${files} Create Dictionary files=${file_data}
Set to Dictionary ${files}
Log ${files}
Log ${data}
${resp} RequestsLibrary.Post Request ALias finance/uploadPayments files=${files} data=${data}
headers=${header}
Log ${resp}
Should Be Equal As Strings ${resp.status_code} 200
Please see example using Postman, this works fine.
headers:
I managed to get this working using Python
import requests
def upload_file(endpoint_url,user_name,file_name,file_path, seperator,file_type):
url = endpoint_url
payload = {'username': user_name, 'delimiter': seperator}
files = {'files': (file_name, open(file_path, 'rb'), file_type, {'Expires': '0'})}
r = requests.post(url, files=files, data=payload)
return r.text
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.