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>

2 Answers2

5

You can't POST XML to Mechanical Turk over REST. It looks like you're confusing REST with SOAP to me.

Mechanical Turk's REST interface only takes URL-encoded key-value pairs, like this:

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
Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61
  • The documentation does mention POSTing to the REST api in multiple places. However, it doesn't cover it in full detail. As it is mentioned in the forums, and by AWS chat support. GET requests are limited to <8k characters. –  Aug 21 '13 at 11:16
  • http://docs.aws.amazon.com/AWSMechTurk/2008-08-02/AWSMechanicalTurkRequester/MakingRequests_MakingRESTRequestsArticle.html –  Aug 21 '13 at 11:19
  • @c-qjv0xfi You cannot post XML unless you use SOAP. The documentation is quite clear. You need to either URL-encode your request or use SOAP. – Fredrick Brennan Aug 21 '13 at 13:21
1

I had mixed up the POST requests parameters. For MTURK REST API, you do not POST the XML structure, but headers+values to the indicated URL.

Instead of URL params, you POST them as params in the POST body.

For example the GET request below:

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

Would become:

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

Where everything below the URL is the POST body.

Hope this helps somebody.