I am very new to python and robot framework and it would be great if someone could point out what is the mistake that I am doing. I am creating a simple function which will do a POST request to a test management tool called Zephyr and upload the Results. I have copied the code from 'Postman'(it works perfectly there) but doesn't seem to run from the Robot file. It is giving me a the error as:
{"errorCode":400,"message":"HTTP 400 Bad Request"}
My code:
import requests
def upload_to_zephyr():
url = "https://api.zephyrscale.smartbear.com/v2/automations/executions/junit?projectKey=someKey"
payload = {}
files = [('file', ('junitresult.xml', open('/path-to-results/junitresult.xml', 'rb'), 'text/xml'))]
headers = {
'Content-Type': 'multipart/form-data',
'Authorization': 'Bearer token value'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
I have saved this in a file called uploadToZephyr.py
. And then I have created a simple robot framework test to call this file. Both the python file and the robot file are in the same location.
*** Settings ***
Library uploadToZephyr.py
*** Variables ***
*** Test Cases ***
Upload Results to Zephyr
upload_to_zephyr
*** Keywords ***