WATO API <302 Found>

Hello everyone,

I’m facing a problem trying to use the WEB API through curl, I’m doing a basic test to see if it works, I’m using the following command:

curl “http://192.168.142.250/SigMon/check_mk/webapi.py?action=get_all_hosts&_username=automation&_secret=KVUDUMWKUPOEQSWU@NDC&request_format=python&output_format=python

The output for it is:

It means, it was found, but why is it not returning with the hosts registered on check_mk instead?

Note: My check MK Server is a CentOS7 with Python 2.7.5 and I’m trying to run the curl command through a Ubuntu with python 3.8.2, I tried localhost on Check MK but I get the same error.

Any suggestions?

Your Apache tries to forward to a localhost with HTTPS. How is your server configured?
What happens if your curl command already uses HTTPS?

HTTP and HTTPS running on default ports

I tried the curl through HTTPS and the output is:

Command:

curl “https://localhost:443/SigMon/check_mk/webapi.py?action=get_all_hosts&_username=automation&_secret=KVUDUMWKUPOEQSWU@NDC&request_format=python&output_format=python” -k

Output:
image

Although the user and password are correct, I followed the example on https://checkmk.com/cms_wato_user.html#automation with automation user.

I’m using omd-consol-labs.2.90 and Check MK Raw 1.2.8p20

There is no webapi with this old CMK version.
I don’t remember it correctly but 1.5.0 is minimum needed for the API.

1.2.8 already had the API, but very limited.

This looks more like an authentication / authorization error.

Does the automation user has the Administrator role?

I will need just to create a few hosts, nothing more, even this old version can work for me.

Yes, the automation user has Administrator role:
image

The roles are correct too, all is default from check_mk, I didn’t personalize nothing

Sorry mistake on my part – then i would also look for @r.sander’s direction and from the first call the redirect to localhost is a little bit strange. Not that there is a problem also inside the Apache.