MLister
MLister

Reputation: 10310

HIT instance has no attribute 'Title' for HITs returned by boto

I'm using the boto library to play around with Amazon MTurk. I want to retrieve some reviewable HITs, and display their properties. For example:

hits = self.mturk_conn.get_reviewable_hits(page_size=30, status='Reviewable', sort_by='Expiration', sort_direction='Ascending', page_number=1)

for h in hits:
    print '%s: %s' % (h.HITId, h.Title)

I do manage to get HITId, but for some reason I cannot get Title as I get this error msg:

AttributeError: HIT instance has no attribute 'Title'

A look at AWS API (http://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_HITDataStructureArticle.html) suggests that the property should be there. In fact, if I get individual HIT through get_hit method of boto, Title property exists. Any reason why this does not work for the HITs returned by get_reviewable_hits method?

Upvotes: 0

Views: 431

Answers (1)

Fredrick Brennan
Fredrick Brennan

Reputation: 7357

Take a look at an example response for the actual operation that you are calling.

While the singular GetHIT call returns a full HIT data structure.

As you can see in the article for the HIT data structure, not all of the attributes are required.

It depends on the API call you make which attributes the HIT response object has. (Confusing, right!?)

In this case you actually have to call GetReviewableHITs, then use the HITId returned for GetHIT to get a full structure that includes the Title attribute.

By the way, instead of using Boto you might use my Python mTurk API which uses the exact names in the API docs :)

Upvotes: 2

Related Questions