# Disable notification for service on the host via API

**URL:** <https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248>\
**Category:** Icinga 2\
**Created:** [February 17, 2022, 3:34pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248 "2022-02-17T15:34:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [February 17, 2022, 3:34pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/1 "2022-02-17T15:34:00Z")

</div>

Hi guys!  
I need to disable notifications for several services on a lot of hosts.  
Yeah, through Director it’s easy for one or two hosts but I have over 50 hosts and this simple task become a monkey job(  
Could you advise how I can disable notification for a particular service on a host using API?  
Thanks for any help!

---

<div class="post-metadata">

**Author:** ![Al2Klimov](https://community.icinga.com/user_avatar/community.icinga.com/al2klimov/32/959_2.png) [@Al2Klimov](https://community.icinga.com/u/Al2Klimov)\
**Post date:** [February 17, 2022, 4:19pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/2 "2022-02-17T16:19:32Z")

</div>

Hello @akontiy!

Could you change your notification apply rules in Director?

Best,  
A/K

---

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [February 17, 2022, 4:29pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/3 "2022-02-17T16:29:04Z")

</div>

Hmm, as a variant if API can’t

---

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [February 18, 2022, 11:02am UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/4 "2022-02-18T11:02:45Z")

</div>

If I can **GET** attr on a service:

```auto
curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X GET 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": ["enable_notifications"], "pretty": true }'
Enter host password for user 'director':
{
    "results": [
        {
            "attrs": {
                "enable_notifications": true
            },
            "joins": {},
            "meta": {},
            "name": "HOST!check_cpu_load",
            "type": "Service"
        }
    ]
}

```

Then I can change it, but no( :

```auto
curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'
Enter host password for user 'director':
{
    "error": 400.0,
    "status": "Invalid type for 'attrs' attribute specified. Array type is required."

}

```

Tried as an array but also no 🥲

---

<div class="post-metadata">

**Author:** ![yhabteab](https://community.icinga.com/letter_avatar_proxy/v4/letter/y/ac91a4/32.png) [@yhabteab](https://community.icinga.com/u/yhabteab)\
**Post date:** [February 21, 2022, 4:35pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/5 "2022-02-21T16:35:54Z")

</div>

> `curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'`

You are still sending a `GET` request this way and not `POST`, since you are overriding the actual post request with `X-HTTP-Method-Override: GET`. You might want to try it this way, then it should work.

```bash
curl -k -s -u 'director' -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'

```

---

<div class="post-metadata">

**Author:** ![akontiy](https://community.icinga.com/user_avatar/community.icinga.com/akontiy/32/5242_2.png) [@akontiy](https://community.icinga.com/u/akontiy)\
**Post date:** [February 21, 2022, 5:25pm UTC](https://community.icinga.com/t/disable-notification-for-service-on-the-host-via-api/9248/6 "2022-02-21T17:25:50Z")

</div>

Omg, I feel so stupid…  
Thank you @yhabteab!
