问题描述
我正在尝试使用 HTMLQuestion 数据结构和 boto3 的资格测试构建 XML 以提交给 Amazon 的 Mechanical Turks 服务。我遵循 https://katherinemwood.github.io/post/qualifications/ 中的示例。不行,控制台输出错误:
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'
我尝试遵循 Building HTMLQuestion XML for boto3 MTurk
中的示例我认为错误只是在 question.xml 文件中,所以我只是更改了它的内容。我从上面链接中的 xml 复制内容。
对于python文件:
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'])
有谁知道为什么这段代码不起作用?或者我应该如何格式化 xml 文件? 我在 linux 18.04 中使用可视化代码。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)