Fix for CreateQualificationType returning 400 error using rturk

Update 7/14/11 – I believe this is fixed in rturk 2.4 – thanks Mark!
http://rubygems.org/gems/rturk
***
rturk, the Ruby gem for making calls to the Amazon Mechanical Turk API, uses a REST transport layer. That’s fine, but all calls are currently performed by a GET, which has a length limitation. When making calls that include long strings of data – such as the XML for a QuestionForm structure in a qualification tests – errors may occur with the non-explanatory message ‘400 Request Error’.

Was able to patch it by making a change to lib/rturk/requester.rb :

46,47c46,50
< RTurk.logger.debug "Sending request:\n\t #{credentials.host}?#{querystring}"
< RestClient.get("#{credentials.host}?#{querystring}")
---
> # RTurk.logger.debug “Sending request:\n\t #{credentials.host}?#{querystring}”
> # RestClient.get(”#{credentials.host}?#{querystring}”)
>
> RTurk.logger.debug “Posting request to #{credentials.host}:\n\t #{params.inspect}”
> RestClient.post(credentials.host.to_s, post_params)

A more robust fix might be to use POST only for longer requests, or make it an explicit option on the RTurk object

Leave a Reply