6

I'm using the Python AWS package boto v2.7 to interact with the Mturk API to create and manage HIT's etc.

I'm getting stuck when trying to create a HIT using an existing template. Amazon's documentation on the topic is here: http://docs.aws.amazon.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_CreateHITOperation.html

My code is:

from boto.mturk.connection import MTurkConnection

mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                             aws_secret_access_key=SECRET_KEY,
                             host=HOST)

mtc.create_hit(hit_layout=HIT_LAYOUT_ID)

The error is:

MTurkRequestError: MTurkRequestError: 200 OK
<?xml version="1.0"?>
<CreateHITResponse><OperationRequest><RequestId>986926dd-0263-4aca-970c-139b7ed4a0e8</RequestId></OperationRequest><HIT><Request><IsValid>False</IsValid><Errors><Error><Code>AWS.MechanicalTurk.InvalidParameterValue</Code><Message>There was an error parsing the request (1359492767224 s)</Message></Error></Errors></Request></HIT></CreateHITResponse>

It seems like the MTurk API is expecting an hit layout parameter as detailed here: http://docs.aws.amazon.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_HITLayoutArticle.html

While my original template did make use of placeholder values, I deleted them for the sake of simplicity and to just try to get the code working. In this case I'd think that the only parameter required would be the hit_layout?

Is this a limitation on boto's api or am I missing something here?

UPDATE

I tried using the mturkcore module mentioned in the comments with the following results.

Code:

import mturkcore

login_dict = {'use_sandbox':True,
              'stdout_log':False,
              'AWS_ACCESS_KEY_ID':'ACCESS_ID',
              'AWS_SECRET_ACCESS_KEY':'PASSWORD'}

mtc = mturkcore.MechanicalTurk(login_dict)

request_params = {"Title":"Test Layout",
                    "Description":"Test Description",
                    "HITLayoutId":"2QNNJKM05BMJLZIA6G7TS9RA7TECHE",
                    "Reward":0.05,
                    "LifetimeInSeconds":6000,
                    "AssignmentDurationInSeconds":600    
                    }

mtc.create_request("CreateHIT", request_params)

This yields an error msg from suds:

TypeNotFound: Type not found: 'HITLayoutId'

Again, I'm following the instructions here: http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_CreateHITOperation.html which seem fairly straight forward.

SOLUTION I was finally able to create a HIT from an existing template, but only in the production environment. Apparently there are differences between sandbox and production which is probably why I was getting the above error. If anybody has had success with doing this in the sandbox, please chime in!

Additionally, you must ensure that the Reward, LifetimeInSeconds, and AssignmentDurationInSeconds parameters match the layout template you're creating. Finally, to view the HIT you created, you must click on the "Manage HITs Individually" link.

ChrisArmstrong
  • 2,491
  • 8
  • 37
  • 60
  • You've got a lot going on here. What's a “HIT Layout” supposed to be? A QuestionForm? The response from RegisterHITType? Something else? The Boto mTurk interface is quite bad in that many things are renamed and few things make sense, [I wrote my own Python mTurk API to solve these issues somewhat.](http://mturkconsultant.com/blog/index.php/2013/01/my-python-mechanical-turk-api-mturkcore-py/) – Fredrick Brennan Jan 30 '13 at 01:03
  • cool, I'll give this a whirl tomorrow and let you know how I make out. – ChrisArmstrong Jan 30 '13 at 02:31
  • The layoutid only refers to the template itself, not any of the HIT parameters, so you still have to specify them. Also, the production and sandbox servers are completely separate...so if you create a template in the sandbox, you would need to recreate in production (and get the new corresponding layoutid) to create a hit with it there. – Thomas May 07 '13 at 09:22

0 Answers0