Search code examples
google-workflows

how to pass some arguments to a workflows from a parent workflows


I have a workflow which is a complicated loop. I would like to reuse it so I made it into a separate workflow. Now I need to call it at different places in a parent workflow using different parameters. I keep getting an error which seems to indicate that I am not passing the arguments correctly. You will find below the way I call it and the error message. Any help appreciated

 - testCallable2:
        call: http.post
        args:
            url: ${"https://workflowexecutions.googleapis.com/v1beta/projects/"+sys.get_env("GOOGLE_CLOUD_PROJECT_ID")+"/locations/us-central1/workflows/test-callable/executions"}
            auth: 
                type: OAuth2
                scope: 'https://www.googleapis.com/auth/cloud-platform'
            body:
                - argv1: 1
                - argv2: "one"
        result: state

-error

 "error": {
  "code": 400,
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.BadRequest",
      "fieldViolations": [
        {
          "description": "Invalid JSON payload received. Unknown name \"\": Root element must be a message."
        }
      ]
    }
  ],
  "message": "Invalid JSON payload received. Unknown name \"\": Root element must be a message.",
  "status": "INVALID_ARGUMENT"
}

Solution

  • You don't need the dashes for the body section

    instead of this:

    body:
      - argv1: 1
      - argv2: "one"
    

    use:

    body:
      argv1: 1
      argv2: "one"