I'm trying to build XML to submit to Amazon's Mechanical Turks service using the HTMLQuestion data structure and boto3's Qualification Test. I follow example in https://katherinemwood.github.io/post/qualifications/. It doesn't work, console output error:
botocore.exceptions.ClientError: An error occurred (ParameterValidationError) when calling the CreateQualificationType operation: There was an error parsing the XML question or answer data in your request. Please make sure the data is well-formed and validates against the appropriate schema. Details: cvc-elt.1: Cannot find the declaration of element 'Question'
I try to follow example in Building HTMLQuestion XML for boto3 MTurk
I think error just in question.xml file so i just change content of it. I copy content from xml in link above.
for python file:
import boto3
questions = open('question.xml', mode='r').read()
answers = open('answer.xml', mode='r').read()
region_name = 'us-east-1'
aws_access_key_id='my_aws_key'
aws_secret_access_key='my_other_aws_key'
endpoint_url = 'https://mturk-requester-sandbox.us-east-1.amazonaws.com'
# Uncomment this line to use in production
# endpoint_url = 'https://mturk-requester.us-east-1.amazonaws.com'
mturk = boto3.client(
'mturk',
endpoint_url=endpoint_url,
region_name=region_name,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
)
# This will return $10,000.00 in the MTurk Developer Sandbox
client = mturk
print(client.get_account_balance()['AvailableBalance'])
qual_response = mturk.create_qualification_type(
Name='Color blindness test',
Keywords='test, qualification, sample, colorblindness, boto',
Description='This is a brief colorblindness test',
QualificationTypeStatus='Active',
Test=questions,
AnswerKey=answers,
TestDurationInSeconds=300)
print(qual_response['QualificationType']['QualificationTypeId'])
Does anyone have any idea why this code doesn't work? Or maybe how should i format xml file ?
I'm using visual code in linux 18.04.
question from:
https://stackoverflow.com/questions/65557364/cannot-find-the-declaration-of-element-htmlquestion-in-boto3-of-mturk 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…