API call runbook and pass variables | Nutanix Community
Skip to main content
Solved

API call runbook and pass variables

  • November 11, 2021
  • 2 replies
  • 421 views

I have the same question as in topic (https://next.nutanix.com/calm-application-management-55/passing-variables-to-calm-runbooks-39356)

I have created a runbook, configured a variable  under the “Configuration” section of the runbook.

I can launch the runbook via API, but it does not pass the value.
I tried passing the below sample as the body of the request.

What am I missing ? 

 

{
    "spec": {
        "args": [
            {
                "name": "VariableName",
                "value": "value"
            }
        ]
    }
}

 

Best answer by JoseNutanix

Hi Peter,

I have tested again and it is working for me. Steps to reproduce:

  1. Create a runbook with a single Execute Escript task that has: 
    print(“@@{VAR_TEST}@@”)
  2. Add in the runbook a variable called VAR_TEST and enable runtime icon

     

  3. Gather the UUID for the runbook from the URL on the top

     

  4. With Postman or curl, run a POST call to https://PC_IP:9440/api/nutanix/v3/runbooks/<runbook_uuid>/run with body that has:
    {
        "spec": {
            "args": [
                {
                    "name": "VAR_TEST",
                    "value": "THIS IS A TEST"
                }
            ]
        }
    }

     

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

2 replies

JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • 150 replies
  • Answer
  • November 11, 2021

Hi Peter,

I have tested again and it is working for me. Steps to reproduce:

  1. Create a runbook with a single Execute Escript task that has: 
    print(“@@{VAR_TEST}@@”)
  2. Add in the runbook a variable called VAR_TEST and enable runtime icon

     

  3. Gather the UUID for the runbook from the URL on the top

     

  4. With Postman or curl, run a POST call to https://PC_IP:9440/api/nutanix/v3/runbooks/<runbook_uuid>/run with body that has:
    {
        "spec": {
            "args": [
                {
                    "name": "VAR_TEST",
                    "value": "THIS IS A TEST"
                }
            ]
        }
    }

     


  • Author
  • Voyager
  • 1 reply
  • November 11, 2021

The issue was caused by the fact I did not enable the “enable runtime”  option.

 

Many thanks for the prompt reply!