API Error Hosrtgroups - HTTP Error 414: Request Too Long

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
sgomeztd
Posts: 32
Joined: Tue Apr 30, 2019 11:00 am

Re: API Error Hosrtgroups - HTTP Error 414: Request Too Lon

Post by sgomeztd »

Hi,

Checking your solution I think the problems was that I was passing everything on the url using put while in your example you use POST and divide the call in url + body. It seems the url limit is only for the url itself but not the body as my hostgroup got updated from 260 host to 388 using that api call.

I adapted your example to Ansible and now it works OK as expected.

Code: Select all

      - name: "[ADDING TO NAGIOS] Append {{ inventory_hostname }} to hostgroup {{OS}}"
        ansible.builtin.uri:
            url:  "https://192.168.1.20/nagiosxi/api/v1/config/hostgroup?apikey={{ xi_api_key }}&pretty=1"
            method: POST
            body: "hostgroup_name={{OS}}&alias={{OS}}&members={{ hostgroup_add.json[0].members | flatten | join (',') }},{{ inventory_hostname }}"
            validate_certs: no
            status_code: 200
        delegate_to: localhost
        register: new_hostsgroup
        failed_when: hostgroup_add.json.error is defined
        when: hostgroup_add.json[0].members is defined or hostgroup_add.exception is defined
Thank for your help, feel free to mark this post as solved.
User avatar
pbroste
Posts: 1288
Joined: Tue Jun 01, 2021 1:27 pm

Re: API Error Hosrtgroups - HTTP Error 414: Request Too Lon

Post by pbroste »

Excellent, @sgomeztd I am glad that we were able to help dial things in so you could dial this in.

Locking this,
Perry

We're moving to a new support system!

The Nagios Answer Hub is a place where you can get help with technical questions from our experts. There, you can quickly open tickets and join discussion boards.

Request Nagios Answer Hub access here: https://info.nagios.com/answer-hub-access-new-users

After completing the access form, you will be given access to a portal where new tickets can be created. We will keep the old customer forum sections and ticket system available for current cases to be resolved.
Locked