From: "Dan Callaghan" <dcallagh(a)redhat.com>
To: "beaker-devel" <beaker-devel(a)lists.fedorahosted.org>
Sent: Thursday, 19 February, 2015 2:02:31 PM
Subject: Re: [Beaker-devel] Receiving HTML rather than JSON despite Accept header
Excerpts from Nick Coghlan's message of 2015-02-19 12:46 +10:00:
> Hi folks,
>
> I'm trying to use the HTTP APIs documented in
>
https://beaker-project.org/docs-release-19/server-api/http.html as
> follows:
>
> curl --negotiate -H 'Accept: application/json' https://<Beaker
> server domain>
>
> I have a valid Kerberos ticket, but the main page just returns the
> HTML list of systems, while the subcollections for available, free and
> my systems return a login page redirect.
>
> So it appears either something is broken or the API documentation has
> omitted a required setup step.
The endpoints for listing systems (/, /available/, /free/, /mine/) don't
actually offer JSON at all right now. Only Atom or the human-readable
HTML with grid.
The docs are a bit confusing on this point since they mention "pageable
JSON collections" at the very top and then right below it describes the
system listing endpoints. But those are not "pageable JSON collections".
The only two resources that are pageable JSON collections in 19 are
/systems/<fqdn>/activity/ and /systems/<fqdn>/commands/. As we add new
Flask-based APIs they will be consistent.
But the system listing endpoints are much, much older (Beaker 0.6) and
are using the old TG @paginate stuff which is why they are not
consistent with any of the newer APIs. We could probably make the docs
call out this inconsistency more explicitly.
Indeed, that was exactly my point of confusion - I forgot that those APIs were currently
still HTML & XML only, as the intro section talked specifically about the design of
the new APIs rather than the legacy ones.
I got the main listing to work with the following:
curl --negotiate 'https://<server>?tg_format=atom&list_tgp_limit=0'
And figured out this sed hack to extract just the host names:
curl -s --negotiate
'https://<server>?tg_format=atom&list_tgp_limit=0' | sed -n
's_.*<id>.*/view/\(.*\)</id>.*_\1_p'
However, the qualified listings still came back as a login redirect rather than giving me
any data, even with a valid Kerberos ticket and passing --negotiate to curl.
Cheers,
Nick.
--
Nick Coghlan
Red Hat Hosted & Shared Services
Software Engineering & Development, Brisbane
HSS Provisioning Architect