1

On my api I have a route with a path parameter: api.com/item/{id} I cannot generate the path directly from the stpefunction. I tried to concatenate the static part and the dynamic part using the intriseque function but I got this error: Reference path didn't start with '$' and I did not find any parameter to enter a path parameter in the doc

{
  "Comment": "Stepfunction",
  "StartAt": "Generate random ID",
  "States": {
    "Generate random ID": {
      "Type": "Task",
      "Resource": "${GetRandomFunctionArn}",
      "ResultPath": "$",
      "Next": "Get item"
    },
    "Get item": {
      "Type": "Task",
      "Resource": "arn:aws:states:::apigateway:invoke",
      "Parameters": {
        "ApiEndpoint": "${APIBaseUrl}",
        "Method": "GET",
        "RequestBody": {},
        "AuthType": "NO_AUTH",
        "Stage": "${APIStage}",
        "Path": "States.Format(${EndpointProductAvailability}/{}, $.item_id)"
      },
      "End": "True"
    }
  }
}

The stepfunctin is part of a sam application.

How to make an api call with one part which is an input variable and the rest which is generated by a previous task?

2
  • You might need to set .$ after Path: "Path.$": "States.Format(${EndpointProductAvailability}/{}, $.item_id)". Commented Feb 17, 2021 at 15:59
  • I try too but i have the same error ... Commented Feb 17, 2021 at 17:18

1 Answer 1

1

You path should be something like this:

As per this AWS Step Functions adds updates to ‘choice’ state, global access to context object, dynamic timeouts, result selection, and intrinsic functions to Amazon States Language

"Path.$": "States.Format('{}', $.item_id)"

the above works for me.

{
  "Parameters": {
    "foo.$": "States.Format('Hello, {} {}', $.firstName, $.lastName)"
  }
}

So as you shared your URL path is something like api.com/item/{id}

"Path.$": "States.Format('item/{}', $.item_id)"

Should also work.

The other I see is something like this, Generate random ID generates output like below:

{
 "apipath": "item/",
 "item_id": "1213"
}
"Path.$": "States.Format($.apipath, $.item_id)"

Intrinsic functions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.