# Notifications API Create Channel 502 Error

**URL:** <https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091>\
**Category:** OpenSearch\
**Tags:** notifications\
**Created:** [February 26, 2024, 10:19pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091 "2024-02-26T22:19:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazyadmin](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@crazyadmin](https://forum.opensearch.org/u/crazyadmin)\
**Post date:** [February 26, 2024, 10:19pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/1 "2024-02-26T22:19:16Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser): OpenSearch v2.11

**Describe the issue** :  
The Notifications API feature to create a notifications channel appears to not work in 2.11. I have the same issue in two clusters on 2.11. This feature is documented here: [API - OpenSearch Documentation](https://opensearch.org/docs/2.11/observing-your-data/notifications/api/#create-channel-configuration)

The “create channel” API request times out with a HTTP 502 error:

```auto
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Proxy Error</title>
</head><body>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request<p>Reason: <strong>Error reading from remote server</strong></p></p>
</body></html>

```

I can upgrade to 2.12 if this is fixed in that version, but I didn’t see anything about this issue in the release notes.

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [February 26, 2024, 10:31pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/2 "2024-02-26T22:31:29Z")

</div>

@crazyadmin How did you execute your API? Could you share it?  
I’ve just tested 2.11.0 and Dev Tools using an example API Channel from the OpenSearch Docs.

> **[API](https://opensearch.org/docs/2.11/observing-your-data/notifications/api/#create-channel-configuration)**
>
> Notifications API

```auto
POST /_plugins/_notifications/configs/
{
  "config_id": "sample-id",
  "name": "sample-name",
  "config": {
    "name": "Sample Slack Channel",
    "description": "This is a Slack channel",
    "config_type": "slack",
    "is_enabled": true,
    "slack": {
      "url": "https://sample-slack-webhook"
    }
  }
}

```

response

```auto
{
  "config_id": "sample-id"
}

```

GET \_plugins/\_notifications/configs

```auto
{
  "start_index": 0,
  "total_hits": 1,
  "total_hit_relation": "eq",
  "config_list": [
    {
      "config_id": "sample-id",
      "last_updated_time_ms": 1708986627847,
      "created_time_ms": 1708986627847,
      "config": {
        "name": "Sample Slack Channel",
        "description": "This is a Slack channel",
        "config_type": "slack",
        "is_enabled": true,
        "slack": {
          "url": "https://sample-slack-webhook"
        }
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![crazyadmin](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@crazyadmin](https://forum.opensearch.org/u/crazyadmin)\
**Post date:** [February 27, 2024, 5:06pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/3 "2024-02-27T17:06:06Z")

</div>

I’ve tried using Dev Tools and through curl on both clusters, same issue. The example with a Slack channel from the documentation doesn’t work, either. Dev Tools and curl have both worked in the past, but I noticed it had broken shortly after upgrading to 2.11. I have a lot of other API calls scripted using curl, including other Notifications API calls, but this call doesn’t work.  
The Dev Tools method is just a copy/paste from the documentation example. Here’s the curl command if you’re interested:

```auto
  curl -nk -X POST "https:/0.0.0.0:9200/_plugins/_notifications/configs" \
      -H 'osd-xsrf: true' \
      -H 'Content-Type: application/json' \
      --data @<(cat $JSONfilename)

```

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [February 28, 2024, 2:18pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/4 "2024-02-28T14:18:51Z")

</div>

@crazyadmin You’re missing authentication.

```auto
curl -nk -X POST "https:/0.0.0.0:9200/_plugins/_notifications/configs" \
      -u admin:admin \
      -H 'osd-xsrf: true' \
      -H 'Content-Type: application/json' \
      --data @<(cat $JSONfilename)

```

---

<div class="post-metadata">

**Author:** ![crazyadmin](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@crazyadmin](https://forum.opensearch.org/u/crazyadmin)\
**Post date:** [February 28, 2024, 2:35pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/5 "2024-02-28T14:35:43Z")

</div>

The ‘-n’ flag is handling authentication here without needing to specify the credentials in the command line. This method is used about a dozen times in the same script and works for the other API calls it does. Regardless, the Dev Tools way should still work.

---

<div class="post-metadata">

**Author:** ![crazyadmin](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@crazyadmin](https://forum.opensearch.org/u/crazyadmin)\
**Post date:** [February 28, 2024, 5:08pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/6 "2024-02-28T17:08:32Z")

</div>

Here’s the cluster log when trying to use the documented example in Dev Tools. This sequence repeats over and over until failure:

```auto
[2024-02-28T11:06:57,714][INFO][o.o.n.i.ConfigIndexingActions] [test-logdash] notifications:NotificationConfig-create
[2024-02-28T11:07:27,713][WARN][o.o.n.a.PluginBaseAction] [test-logdash] notifications:IllegalStateException:
kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 60000 ms
        at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:186) ~[?:?]
        at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:156) ~[?:?]
        at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:497) ~[?:?]
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274) ~[?:?]
        at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:69) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[2024-02-28T11:07:27,714][WARN][r.suppressed] [test-logdash] path: /_plugins/_notifications/configs/, params: {pretty=true}
org.opensearch.OpenSearchStatusException: Timed out waiting for 60000 ms
        at org.opensearch.notifications.action.PluginBaseAction$doExecute$1.invokeSuspend(PluginBaseAction.kt:97) [opensearch-notifications-2.11.1.0.jar:2.11.1.0]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) [kotlin-stdlib-1.8.21.jar:1.8.21-release-380(1.8.21)]
        at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:113) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) [kotlin-stdlib-1.8.21.jar:1.8.21-release-380(1.8.21)]
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]

```

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [February 29, 2024, 11:24am UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/7 "2024-02-29T11:24:01Z")

</div>

@crazyadmin I’m not getting any of these errors in my test lab. Is it 2.11.0 or 2.11.1?

How did you deploy your cluster? Is an upgrade or fresh installation?

---

<div class="post-metadata">

**Author:** ![crazyadmin](https://avatars.discourse-cdn.com/v4/letter/c/3da27b/32.png) [@crazyadmin](https://forum.opensearch.org/u/crazyadmin)\
**Post date:** [March 1, 2024, 3:08pm UTC](https://forum.opensearch.org/t/notifications-api-create-channel-502-error/18091/8 "2024-03-01T15:08:38Z")

</div>

2.11.1. It was an upgrade from v2.7 in both cases.
