Can't add an attachment in a result of run using create_test_result_attachment for v6.0 api
Able to resolve it.. Issue was with file_name. Instead of passing report, needed to extract the html file and it worked. Added code: filename = Path(report).name with open(report, 'rb') as f: encoded_string = base64.b64encode(f.read()).decode('ascii') test_client = self.connection.get_client(TEST_CLIENT) Test_Attachment_Request_Model={ 'attachment_type': 'GeneralAttachment', 'comment': 'attach report', 'file_name': filename, 'stream': encoded_string }
When i am trying to attach results using create_test_result_attachment api, getting error message "msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='dev.azure.com', port=443): Max retries exceeded with url: /itron/4fc412f1-9337-4c85-8aaf-7955d066a31c/_apis/test/Runs/3878830/Results/100000/Attachments (Caused by ResponseError('too many 500 error responses',))"
code:
report ='//home//shweta//Desktop//test.html'
with open(report, 'rb') as f:
encoded_string = base64.b64encode(f.read()).decode('ascii') test_client = self.connection.get_client(TEST_CLIENT)
Test_Attachment_Request_Model={
'attachment_type': 'GeneralAttachment',
'comment': 'attach report',
'file_name': report,
'stream': encoded_string
}
res = test_client.create_test_result_attachment(Test_Attachment_Request_Model, project, run_id, test_case_result_id)
print(res)
Error: msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='dev.azure.com', port=443): Max retries exceeded with url: /itron/4fc412f1-9337-4c85-8aaf-7955d066a31c/_apis/test/Runs/3878830/Results/100000/Attachments (Caused by ResponseError('too many 500 error responses',))