Get API Requests for New Host Action

Hi,

Does the Foreman GUI use the API on the backend?

I have been able to successfully create a New Host through the Foreman Web
UI. I want to do the exact same thing in an automated manner.

Is there any way to sniff the API requests the Web UI makes, maybe through
tailing a log file. Then I would like to be able to replicate this through
curl.

I could look through all the parameters in Foreman and
keep on trying. I am looking for a shortcut.

Thanks,

Chuan

The foreman UI does not use the API primarily (there are probably minor calls to dynamically load some info via ajax requests). Your best bet might be to watch the traffic from the hammer-cli against the server (which does use the v2 api). However, what aspects of the documented api do you think would help you accomplish your task?

··· ----- Original Message ----- > Hi, > > Does the Foreman GUI use the API on the backend? > > I have been able to successfully create a New Host through the Foreman Web > UI. I want to do the exact same thing in an automated manner. > > Is there any way to sniff the API requests the Web UI makes, maybe through > tailing a log file. Then I would like to be able to replicate this through > curl. > > I could look through all the parameters in http://theforeman.org/api.html and > keep on trying. I am looking for a shortcut. > > Thanks, > > Chuan > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout. >

Hi I solved my problem. Here is what I did.

I used the User Interface to create a new Host. I used Chrome's Network
Inspector to look at the POST query the Web UI made to /hosts.

I copied down all the parameters and did some scripting to generate a curl
request. I then pointed this curl request to /api/hosts/.

It worked.

Thanks,

Chuan

··· On Monday, July 14, 2014 4:12:41 PM UTC-4, Tom McKay wrote: > > > > ----- Original Message ----- > > Hi, > > > > Does the Foreman GUI use the API on the backend? > > > > I have been able to successfully create a New Host through the Foreman > Web > > UI. I want to do the exact same thing in an automated manner. > > > > Is there any way to sniff the API requests the Web UI makes, maybe > through > > tailing a log file. Then I would like to be able to replicate this > through > > curl. > > > > I could look through all the parameters in > http://theforeman.org/api.html and > > keep on trying. I am looking for a shortcut. > > > > Thanks, > > > > Chuan > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to foreman-user...@googlegroups.com . > > To post to this group, send email to forema...@googlegroups.com > . > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > > > > The foreman UI does not use the API primarily (there are probably minor > calls to dynamically load some info via ajax requests). Your best bet might > be to watch the traffic from the hammer-cli against the server (which does > use the v2 api). However, what aspects of the documented api do you think > would help you accomplish your task? >

Strictly speaking Tom is correct - however, if you enable debug
logging and create a host in the UI, you'll see the full hash of all
parameters passed to the Create Host action. You can use the same hash
as a starting point for interacting with the API.

Greg

··· On 14 July 2014 21:12, Tom McKay wrote: > The foreman UI does not use the API primarily (there are probably minor calls to dynamically load some info via ajax requests).