0

I'm trying to set up Rturk to outsource some work to Amazon's Mechanical Turk. When I try to create my HITs, I keep running into t he following error in console:

RestClient::BadRequest: 400 Bad Request

When I copy the URL and paste it in my browser to get the response, I get the following message:

This user is not authorized to perform the requested operation

Do you guys have any idea what could be happening here? I am following the rturk documentation on github. https://github.com/mdp/rturk Is it possible that the gem has to be updated?

RTurk.setup(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY_ID'], :sandbox => true)

  hit = RTurk::Hit.create(
    :title => "Sample turk",
    :assignments_duration => 1.hour,
    :expires_at => 1.day.from_now
  ) do |hit|
    hit.lifetime = 1.day
    hit.assignments = 1
    hit.description = "Test description."
    hit.keywords = "places, search, map, location"
    hit.question(mturk-fb_path, :frame_height => 750)
    hit.reward = reward
    if approval_rate
      hit.qualifications.add :approval_rate, { :gt => approval_rate }
    end         if abandoned_rate
      hit.qualifications.add :abandoned_rate, { :lt => abandoned_rate }
    end
    if is_us
      hit.qualifications.add :country, { :eql => "US" }
    end
  end    
}
Huy
  • 10,806
  • 13
  • 55
  • 99

1 Answers1

0

A couple things might be going on here:

  • I don't believe :assignments_duration and :expires_at are valid options. You should be using hit.duration to specify the amount of time a worker has to complete a hit once they accept it and hit.lifetime to set the amount of time until the hit will expire.
  • It might just be a typo in your post, but mturk-fb_path is not a valid ruby variable name. (can't use a dash)

Try starting off with the simplest example that you can build off of once you get it working. This example from rturk should be a good start: https://github.com/mdp/rturk#creating-hits.

Also, I definitely recommend reading through the mturk docs for creating a hit: http://docs.aws.amazon.com/AWSMechTurk/2011-10-01/AWSMturkAPI/ApiReference_CreateHITOperation.html.

Chris Conley
  • 1,062
  • 10
  • 13
  • the path `mturk_fb_path` was a typo on my part. However, I tried starting off trying to create the simplest hit in the sandbox and I'm still getting the same error. Did you have to change any Amazon settings for mechanical turk to work? – Huy Jan 28 '13 at 23:35
  • Hmm, you shouldn't have to change any settings. Have you created a requester sandbox account at https://requestersandbox.mturk.com/? – Chris Conley Jan 29 '13 at 02:13
  • I was able to figure it out. It turns out that the permission for mturk was turned off for my AWS key. There goes half my day. Thanks for your help! :) – Huy Jan 29 '13 at 02:19