- Newest
- Most votes
- Most comments
When triggering a Step Function via an HTTP API, there are several aspects to consider to resolve your 500 Internal Server Error.
First, regarding your request format, when using API Gateway to invoke a Step Function, all Step Functions API actions use the HTTP POST method, so your approach of using a POST request is correct. However, the body structure might need adjustment.
For the request body format when API Gateway is integrated directly with a Step Function, you need to ensure it matches what the StartExecution API action expects. The body should typically include:
- The state machine ARN (if not configured in the mapping template)
- The input for the state machine execution
Your current request structure has an additional nesting level with the input property that might be causing issues. Try modifying your request body to directly include your data:
const requestData = {
Brand: 'TEST'
};
If you've configured a mapping template in API Gateway, make sure your request body aligns with that template's expectations.
To debug a 500 Internal Server Error in this setup:
- Check the CloudWatch Logs for your API Gateway to see the detailed error messages
- Verify the IAM permissions - ensure that API Gateway has the necessary permissions to invoke the Step Function (it needs a role with
AWSStepFunctionsFullAccessor appropriate permissions) - Confirm that the integration is properly set up in API Gateway to call the
StartExecutionAPI action - Test the API directly using tools like Postman or AWS CLI to isolate if the issue is with your frontend code or the API configuration
- Verify that the state machine ARN is correctly specified in your API Gateway configuration
Since your Step Function runs successfully when triggered manually, the issue is likely related to how API Gateway is invoking the Step Function or how your request is structured. Double-check the integration configuration in API Gateway and ensure it's properly set up to call the StartExecution action with the correct parameters.
Sources
Creating a Step Functions API using API Gateway - AWS Step Functions
Starting state machine executions in Step Functions - AWS Step Functions
answered a year ago
