Hi,
That’s a common curl issue, just escape all variable expansions, it works with the following curl call (check the --data
section):
# protocol
protocol="http"
format="json"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="41"
rdeck_token="oB8mmGavKld1VmP8ef9kbR2tXBOyhZfO"
# specific api call info
rdeck_job="fcf8cf5d-697c-42a1-affb-9cda02183fdd"
option_value="hello world, bye world, one, two"
# api call
curl --location --request POST "$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/job/$rdeck_job/run" \
--header "Accept: application/$format" \
--header "X-Rundeck-Auth-Token: $rdeck_token" \
--header "Content-Type: application/$format" \
--data "{ \"argString\":\"-opt1 '$option_value' \" }"
Result:
{
"id": 23,
"href": "http://localhost:4440/api/41/execution/23",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/execution/show/23",
"status": "running",
"project": "ProjectEXAMPLE",
"executionType": "user",
"user": "admin",
"date-started": {
"unixtime": 1667395963318,
"date": "2022-11-02T13:32:43Z"
},
"job": {
"id": "fcf8cf5d-697c-42a1-affb-9cda02183fdd",
"averageDuration": 369,
"name": "TokenWorkflow",
"group": "",
"project": "ProjectEXAMPLE",
"description": "",
"options": {
"opt1": "hello world, bye world, one, two"
},
"href": "http://localhost:4440/api/41/job/fcf8cf5d-697c-42a1-affb-9cda02183fdd",
"permalink": "http://localhost:4440/project/ProjectEXAMPLE/job/show/fcf8cf5d-697c-42a1-affb-9cda02183fdd"
},
"description": "echo ${option.opt1}",
"argstring": "-opt1 \"hello world, bye world, one, two\"",
"serverUUID": "a6e565e0-9fd1-4d51-8596-b0f0186eb46d"
}
Check the Rundeck execution here.
Hope it helps!
--
You received this message because you are subscribed to a topic in the Google Groups "rundeck-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rundeck-discuss/a-rE1lh6B94/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rundeck-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/a2ffe563-cd8b-4c1e-b55e-0ed5afb65a2dn%40googlegroups.com.