有効なXMLであるためには&のパラメータ(たとえば、&)をエスケープする必要があるからです。以下は、動作してこれを実証する完全なRubyコードサンプルです:
require 'aws-sdk'
aws_access_key_id = 'YOUR_ACCESS_ID'
aws_secret_access_key = 'YOUR_SECRET_KEY'
endpoint = 'https://mturk-requester-sandbox.us-east-1.amazonaws.com'
region = 'us-east-1'
# Uncomment this line to use in production
# endpoint = 'https://mturk-requester.us-east-1.amazonaws.com'
#credentials = Aws::Credentials.new(aws_access_key_id, aws_secret_access_key)
mturk = Aws::MTurk::Client.new(endpoint: endpoint) #, credentials: credentials, region: region)
QUESTION = <<END
<ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd">
<ExternalURL>https://s3.amazonaws.com/mturkexternalquestion/untitled.html?color=Red&product_asin=B0100RUSI6</ExternalURL>
<FrameHeight>800</FrameHeight>
</ExternalQuestion>
END
response = mturk.create_hit(title: "Example HIT",
description: "Example HIT",
lifetime_in_seconds: 60 * 60,
assignment_duration_in_seconds: 60 * 5,
max_assignments: 1,
reward: "0.25",
question: QUESTION)
p "Your HIT is created. The HIT ID is #{response.hit.hit_id}"
出典
2018-01-08 17:19:17
jrb