Uploading attachment - results in Bad request (400)


I am trying to upload a simple text file to a manual test with test ID 30014 using Rest API in python. But every time i try to call the Requests.post it result in HTTP error 400 Bad request. I have tried several things but nothing seems to work. I have no idea where i am going wrong. below is the code i am using.

in python:


files = ('text.txt', open('C:/Test/test.txt','rb').read(), 'text/plain')

result = requests.post(url,


                       files = {'file': files},


                       cookies = self.__cookies, verify = self.__cert)

self._oLogger.info("request is %s with the status code: %s ", self.Status[result.status_code],result.status_code)

print result.text

Response is:

INFO: request is Bad request with the status code: 400

{"error_code":"platform.web_application","correlation_id":"3z9yl0k9vqj69hyzy3k71wmoq","description":"HTTP 400 Bad Request","description_translated":"HTTP 400 Bad Request","properties":null,"business_error":false}


If anyone have any idea how i can resolve this, it will be of great help.