Cannot run a job through the REST API

3,201 views
Skip to first unread message

wafrica

unread,
Oct 27, 2011, 2:23:16 PM10/27/11
to rundeck-discuss
I'm using the method described in http://rundeck.org/docs/api/index.html#running-a-job.

Here is a sample of what I'm trying to run

wget -O- "http://my-rundeck-host:4440/api/1/job/my-rundeck-job-id/run?
authtoken=my-auth-token&loglevel=DEBUG&tags=dq3+slave
+search&argString=-BLD_JOB_NAME FULL-Search-trunk -BLD_NUMBER 13 -
DEPLOY_SOLR no -ENV dq3"


But, I get

HTTP request sent, awaiting response... 403 Forbidden
2011-10-27 11:04:32 ERROR 403: Forbidden.

If I use curl I try:


curl --data-urlencode 'argString=-BLD_JOB_NAME FULL-Search-trunk -
BLD_NUMBER 13 -DEPLOY_SOLR no -ENV dq3' "http://my-rundeck-host:4440/
api/1/job/my-rundeck-job-id/run?authtoken=my-rundeck-token"


I get something like:

curl: (6) Could not resolve host: FULL-Search-trunk; No data record of
requested type
curl: (6) Could not resolve host: 13; No data record of requested type
curl: (6) Could not resolve host: no; No data record of requested type
curl: (6) Could not resolve host: dq3'; No data record of requested
type
<result error='true' apiversion='2'><error
code='unauthorized'><message>my-rundeck-user is not authorized fo
r: /api/1/job/my-rundeck-job-id/run</message></error></result>

Greg Schueler

unread,
Oct 28, 2011, 12:34:28 PM10/28/11
to rundeck...@googlegroups.com
Hi wafrica,

It seems that the user is unauthorized...make sure your authtoken is correct

what version of Rundeck are you using?

wafrica

unread,
Oct 28, 2011, 4:56:02 PM10/28/11
to rundeck-discuss
I am running v1.3

The only way I got it to work was by first authenticating by creating
a cookie:

curl -s -S -L -c ./cookies -b ./cookies -d j_username=my-user -d
j_password=my-passwd http://my-rundeck-host:4440/j_security_check >
curl.out

curl -s -S -L -b ./cookies --verbose --data-urlencode "argString=-
BLD_JOB_NAME FULL-Search-trunk -BLD_NUMBER 23 -DEPLOY_SOLR no -ENV
dq3" "http://my-rundeck-host:4440/api/1/job/my-job-id/run"

However, I'd like to use a token instead. Any help there?


On Oct 28, 9:34 am, Greg Schueler <g...@dtosolutions.com> wrote:
> Hi wafrica,
>
> It seems that the user is unauthorized...make sure your authtoken is correct
>
> what version of Rundeck are you using?
>
> On Oct 27, 2011, at 11:23 AM, wafrica wrote:
>
>
>
>
>
>
>
> > I'm using the method described inhttp://rundeck.org/docs/api/index.html#running-a-job.

Greg Schueler

unread,
Oct 28, 2011, 5:36:32 PM10/28/11
to rundeck...@googlegroups.com
You can try using the header instead of URL parameter:

curl -H "X-RunDeck-Auth-Token: TOKEN" ...

Reply all
Reply to author
Forward
0 new messages