AWS CreateHit ruby code

Hi.
I’ve been a C developer since 1988, I know zero about ruby and I
haven’t been enjoying it so far. I have been handed some code.

??? My Question is has anyone every had any success with the Amazon
Mechanical Turk and the CreateHit(…) method… ???

I have upgraded to ruby 1.9.with rvm, and building from source.
I have updated gems
I have installed bundler
I have bundled the required gems… if that is the correct term.
From what I can tell I have the most up to date version of ruby and
gems.

The code I was handed seems to be crashing with no method error in a
call from some gem to to some other gem code several levels deep. I have
dumped out the parameters to CreateHit() that the code passes and it all
looks valid. So from what I see it has little to nothing to do with the
application level code and something wrong in the gem itself(?)

output:

Got account balance: 10000.00
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:127:in `validateResponse’:
AWS.MissingParameters
(Amazon::WebServices::Util::ValidationException)
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:124:in
`each’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:124:in
`validateResponse’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:45:in
`dispatch’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mechan
ic
al_turk.rb:65:in
`method_missing’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/util/c
on
venience_wrapper.rb:22:in
`send’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/util/c
on
venience_wrapper.rb:22:in
`callService’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/util/c
on
venience_wrapper.rb:43:in
`createHITRaw’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/util/c
on
venience_wrapper.rb:50:in
`send’
from

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/util/c
on
venience_wrapper.rb:50:in
createHIT' from mnpr.rb:119:increateSimpleSurvey’
from mnpr.rb:139

Regards,

Regan

After I upgrade the gems and ruby version etc it actually looks like
this:
ruby mnpr.rb lpn
Got account balance: 10000.00
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Connection refused - connect(2) Job was not retrieved.
Reward OK
3600
3600
864000
1
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb:121:in
validateResponse': undefined method[]’ for nil:NilClass
(NoMethodError)
from
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/mturk/mechanical_turk_error_handler.rb:45:in
dispatch' from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/mechanical_turk.rb:65:inmethod_missing’
from
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/util/convenience_wrapper.rb:22:in
callService' from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/util/convenience_wrapper.rb:43:inblock in serviceCall’
from
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/util/convenience_wrapper.rb:50:in
block in serviceCall' from mnpr.rb:129:increateSimpleSurvey’
from mnpr.rb:153:in `’

The line of code in question:

def callService( method, *args )
@service.send( method, *args ) # <------===
end

Between Reward OK and the first error message line is where I have
dumped the parameters to CreateHit(…) call…

Regan

On Aug 30, 2011, at 15:06 , regan russell wrote:

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:127:in `validateResponse’:
AWS.MissingParameters
(Amazon::WebServices::Util::ValidationException)
from

Are you addressing this MissingParameters error?

I googled around and found a test online that shows:

result = @@mturk.createHIT(:Title => ‘Ruby SDK Test Hit’,
:Description => description,
:Keywords => ‘Ruby, test, SDK’,
:Reward => {
:Amount => 23.44,
:CurrencyCode => ‘USD’
},
:Question => question)

Ryan D. wrote in post #1019308:

On Aug 30, 2011, at 15:06 , regan russell wrote:

/Library/Ruby/Gems/1.8/gems/ruby-aws-1.3.1/lib/amazon/webservices/mturk/
me
chanical_turk_error_handler.rb:127:in `validateResponse’:
AWS.MissingParameters
(Amazon::WebServices::Util::ValidationException)
from

Are you addressing this MissingParameters error?

I googled around and found a test online that shows:

result = @@mturk.createHIT(:Title => ‘Ruby SDK Test Hit’,
:Description => description,
:Keywords => ‘Ruby, test, SDK’,
:Reward => {
:Amount => 23.44,
:CurrencyCode => ‘USD’
},
:Question => question)

Thank you for your response. I put in the missing parameters, which is
why my second post doesn’t contain that error. So the answer to your
question is yes.

I didn’t write the code and I don’t know ruby but I downloaded and
installed ruby-debug (rdebug).
I have stepped through the code and inspected variables.

(rdb:1) list
[17, 26] in
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-aws-1.3.2/lib/amazon/webservices/util/convenience_wrapper.rb
17 raise “Missing paramters: #{missing_parameters.join(’,’)}”
unless missing_parameters.empty?
18 @service = args[:ServiceClass].new( args )
19 end
20
21 def callService( method, *args )
=> 22 @service.send( method, *args )
23 end
24
25 def method_missing( method, *args )
26 if @service.respond_to? method

(rdb:1) display method
7: method = GetAccountBalance

GetAccountBalance is missing, yet this seems to be a logical part Amazon
stuff… I am confused and I don’t even kn ow the language.

R.