# Find more details about API # https://qmetrysupport.atlassian.net/wiki/spaces/QPro/pages/377094257/Import+Automation+Results+through+REST+API#ImportAutomationResultsthroughRESTAPI-AutomationAPIDetails import sys #pip3 install requests import requests #requried field url = "https://testmanagement.qmetry.com/rest/import/createandscheduletestresults/1" apiKey = "ENTERAUTOMATIOAPIKEY" filepath = "RESULTFILEPATH" entityType = "RESULTFILEFORMAT" #Supported formats:TESTNG/CUCUMBER/JUNIT/HPUFT/QAF projectID = "PROJET NAME/ID/EKY" # important field # Find more details on below link # https://qmetrysupport.atlassian.net/wiki/spaces/QPro/pages/377094257/Import+Automation+Results+through+REST+API#ImportAutomationResultsthroughRESTAPI-AutomationAPIDetails automationHierarchy ="" #optional field cycleID = "" platformID = "" testsuiteId = "" testsuiteName = "" releaseID = "" buildID = "" if(entityType == ""): print('Enter entityType.') sys.exit() if(filepath == ""): print('Enter file path.') sys.exit() if(url == ""): print('Enter URL.') sys.exit() if(projectID == ""): print('Enter Project Name or key.') sys.exit() files = {'file': open(filepath, 'rb')} payload = {'entityType' : entityType} if(cycleID != ""): payload['cycleID'] = cycleID if(testsuiteId != ""): payload['testsuiteId'] = testsuiteId if(testsuiteName != ""): payload['testsuiteName'] = testsuiteName if(projectID != ""): payload['projectID'] = projectID if(releaseID != ""): payload['releaseID'] = releaseID if(buildID != ""): payload['buildID'] = buildID if(automationHierarchy != ""): payload['automationHierarchy'] = automationHierarchy headers = { 'apikey': apiKey, 'project': projectID, 'Accept':"application/json" } response = requests.request("POST", url, files=files, data=payload, headers=headers) print(response.text)