I am trying to send a python file and some json data to the server via python requests module. Below is the snippet of my code.
files = {'file': (FILE, open('test_hello.py', 'rb'), 'text/plain')}
job_data = dict(name='nice', interval=50, script_path="crap")
r = post(url=url, data=job_data, files=files)
r.status_code
400
r.text
u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>The browser (or proxy) sent a request that this server could not understand.</p>\n'
I am getting status code 400. Can someone please point out what am I missing here ? Or share a correct code snippet ?
PS: I have seen similar questions on stackoverflow but they all give the same error code. I have tried them.
NOTE: I am using Flask 0.10 on server side
UPDATE: The client-side code was working fine. It was my server side Flask code which was bad. It even gave an error message saying "Bad Request"
r.text
400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>The browser (or proxy) sent a request that this server could not understand.'
This error message made me think that client side code is not working as expected even though its looks good and is similar to other stackoverflow questions I have tried.
Thanks to all for responding to the question.