Wrong use of the requests library
shayshei opened this issue · comments
in line 82, you pass the flattened parameters in the params kwarg, instead of the data.
This causes the arguments to be sent in the URL (not really a POST request), and for big arguments, this causes a 400 (bad request) response.
My use case: I created a hit layout, and tried to pass all the text in the parameters. When the text was long, the mturk.request raise an exception because a bad request (400) was returned by the server, and the request.text (line 84) was empty.
The solution is to replace line 82 with:
request = requests.post(self.service_url, data=self.flattened_parameters, verify=self.verify_mturk_ssl)
Thank you for this great API! So much better than boto! :)
Hello,
It's been a long time since I worked on this stuff, but if you take a look at the bottom of http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_AssignQualificationOperation.html (for example) you can see Amazon shows GET requests everywhere. I assumed POST was not allowed.
Their "Making requests" article however says...
The Amazon Mechanical Turk web service supports REST requests for calling service operations. REST requests are simple HTTP requests, using either the GET method with parameters in the URL, or the POST method with parameters in the POST body.
So, I can change it if POST is allowed. Thanks for opening this issue :)
Fixed in 44adb1e