REST API doesn't output JSON

603 views
Skip to first unread message

Bernardo Vale

unread,
Mar 23, 2016, 9:42:43 AM3/23/16
to rundeck-discuss
Hello folks, I'm trying to get started with Rundeck API. I really prefer to parse JSON output and I've read that almost every endpoint can output JSON/XML.

I've added "Accept" and "Content-type" to "application/json" but the output is always XML: 

MY REST CALL:

GET /api/1/system/info HTTP/1.1
Host: myhost.mycompany
Authorization: Basic YmVybmFyZG8udmFsZTpsYjJsYjJsYjI=
Content-Type: application/json
X-Rundeck-Auth-Token: fNMPlj8pHcVJmYpTritvwCX0K4OxfQRx
Accept: application/json
Cache-Control: no-cache

OUTPUT:

<result success='true' apiversion='15'>
    <success>
        <message>System Stats for Rundeck 2.6.2 on node rundeck</message>
    </success>
    <system>
        <timestamp epoch='1458734317289' unit='ms'>
            <datetime>2016-03-23T11:58:37Z</datetime>
        </timestamp>
        <rundeck>
            <version>2.6.2</version>
            <build>2.6.2-1</build>
            <node>rundeck</node>
            <base>/rundeck</base>
            <apiversion>15</apiversion>
            <serverUUID />
        </rundeck>
....
...
...
</result>

Am I missing something?

Pierre-Yves Taczynski

unread,
Mar 23, 2016, 10:04:58 AM3/23/16
to rundeck-discuss
Did you try with only "Accept:application/json"?
Although it should work with both headers.

Results make me think the Accept header is not taken in account.

And just to be sure, did you specify the last api version (15) in the URL?

Bernardo Vale

unread,
Mar 23, 2016, 10:15:36 AM3/23/16
to rundeck-discuss
Hello Pierre, thanks for your help. Yes I've tried with only "Accept" header.

GET /api/15/system/info HTTP/1.1
Host: myhost
Authorization: Basic YmVybmFyZG8udmFsZTpsYjJsYjJsYjI=

X-Rundeck-Auth-Token: fNMPlj8pHcVJmYpTritvwCX0K4OxfQRx
Accept: application/json
Cache-Control: no-cache

The output still XML. And as you can see I'm specifying  API version 15.

Pierre-Yves Taczynski

unread,
Mar 23, 2016, 10:48:29 AM3/23/16
to rundeck-discuss
It will sound stupid but did you try also with curl?

curl -H "Accept:application/json" URL_TO_THE_API//info?authtoken=YOUR_TOKEN

Did you try also another endpoint?

I tried different ways with 2.6.1 and it's ok, so wether there's a problem with 2.6.2 (but not listed in bug fixes 2.6.3 and 2.6.4) wether something is wrong the way you ask the API.


Le mercredi 23 mars 2016 14:42:43 UTC+1, Bernardo Vale a écrit :

Bernardo Vale

unread,
Mar 23, 2016, 12:26:35 PM3/23/16
to rundeck-discuss
Pierre, it's working on Curl:

curl -H "Accept:application/json" -H "X-Rundeck-Auth-Token:mytoke" http://myhost/api/15/system/info

I was using Postman (Chrome Extension) but I still can't figure out what postman it's doing different that the output it's only in XML.

Check it out:


Guirem

unread,
Jan 2, 2017, 1:37:05 PM1/2/17
to rundeck-discuss
Hi,

Same for me here.
It works with curl but not with postman even if I use the code extract feature in curl format from Postman, it will work in command line but will issue xml in postman
Reply all
Reply to author
Forward
0 new messages