0

I'm trying to use the MTurk restful API, and POST to createHIT with a HITTypeID, however, I get the following error:

<?xml version="1.0"?>
<CreateHITResponse>
  <OperationRequest>
    <RequestId>199c9aff-86a4-4280-8d2f-d956a53515b0</RequestId>
  </OperationRequest>
  <HIT>
    <Request>
      <IsValid>False</IsValid>
      <Errors>
        <Error>
          <Code>AWS.MissingParameters</Code>
          <Message>Your request is missing required parameters. Required parameters include Question. Question is a required parameter. (1376962818123)</Message>
          <Data>
            <Key>Parameter</Key>
            <Value>Question</Value>
          </Data>
          <Data>
            <Key>Description</Key>
           <Value>Question is a required parameter</Value>
          </Data>
          <Data>
            <Key>Description</Key>
            <Value>Question is a required parameter</Value>
          </Data>
          <Data>
            <Key>Parameter</Key>
            <Value>Question</Value>
          </Data>
        </Error>
      </Errors>
    </Request>
  </HIT>
</CreateHITResponse>

From my understanding, title should not be required if Hittype is given. So it looks like the API is not actually viewing the POST body.

How would I work around this? Is there anything wrong with my request?

Request:

<CreateHITRequest>
  <HITTypeId>HITTYPEID</HITTypeId>
  <MaxAssignments>1</MaxAssignments>
  <LifetimeInSeconds>604800</LifetimeInSeconds>
  <Question>&lt;QuestionForm Structure&gt;</Question>
</CreateHITRequest>
4

2 回答 2

5

您不能通过 REST 将 XML 发布到 Mechanical Turk。对我来说,您似乎将 REST 与 SOAP 混淆了。

Mechanical Turk 的 REST 接口仅采用 URL 编码的键值对,如下所示

https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester
&AWSAccessKeyId=[the Requester's Access Key ID]
&Version=2012-03-25
&Operation=CreateHIT
&Signature=[signature for this request]
&Timestamp=[your system's local time]
&HITTypeId=T100CN9P324W00EXAMPLE
&Question=[URL-encoded question data]
&LifetimeInSeconds=604800
于 2013-08-20T02:19:45.813 回答
1

我混淆了 POST 请求参数。对于 MTURK REST API,您不发布 XML 结构,而是将标头 + 值发布到指定的 URL。

您可以在 POST 正文中将它们作为参数发布,而不是 URL 参数。

例如下面的 GET 请求:

GET https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester &AWSAccessKeyId=[the Requester's Access Key ID] &Version=2012-03-25 &Operation=CreateHIT &Signature=[signature for this request] &Timestamp=[your system's local time] &HITTypeId=T100CN9P324W00EXAMPLE &Question=[URL-encoded question data] &LifetimeInSeconds=604800

会成为:

POST https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester AWSAccessKeyId=[the Requester's Access Key ID] &Version=2012-03-25 &Operation=CreateHIT &Signature=[signature for this request] &Timestamp=[your system's local time] &HITTypeId=T100CN9P324W00EXAMPLE &Question=[URL-encoded question data] &LifetimeInSeconds=604800

URL 下面的所有内容都是 POST 正文。

希望这可以帮助某人。

于 2013-09-04T15:39:33.297 回答