SerializationException:Start of structure or map found where not expected: API Gateway to Step function

Omkar picture Omkar · Jan 11, 2018 · Viewed 7.9k times · Source

I am using the standard blog tutorial on integrating api gateway with step functions from here: https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-api-gateway.html

My step function expects the following output:

{
  "my_params": {
     "config": "config_value"
  }
}

the Request body needed to do a post request as mentioned in the blog is:

{
 "input": "{}",
   "name": "MyExecution",
   "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld"
}

I am passing my required input like this:

{
 "input": {
           "my_params": {
             "config": "config_value"
             }
          },
  "name": "MyExecution",
  "stateMachineArn": "my-arn"
}

However, I am continuously getting following error:

{
"__type": "com.amazon.coral.service#SerializationException",
  "Message": "Start of structure or map found where not expected."
}

Can someone tell me what exactly is the problem here? What am I doing wrong here? Quick help appreciated.

Answer

Amit Dhara picture Amit Dhara · Mar 28, 2018

Use escape character for your parameters as follows

{
 "input": "{
           \"my_params\": {
             \"config\": \"config_value\"
             }
          }",
  "name": "MyExecution",
  "stateMachineArn": "my-arn"
}