# Creating custom\_webhook throwing 500 internal error, but curl is working fine

**URL:** <https://forum.opensearch.org/t/creating-custom-webhook-throwing-500-internal-error-but-curl-is-working-fine/4322>\
**Category:** Alerting\
**Created:** [December 3, 2020, 6:54am UTC](https://forum.opensearch.org/t/creating-custom-webhook-throwing-500-internal-error-but-curl-is-working-fine/4322 "2020-12-03T06:54:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/elasticheart/32/943_2.png) [@elasticheart](https://forum.opensearch.org/u/elasticheart)\
**Post date:** [December 3, 2020, 6:54am UTC](https://forum.opensearch.org/t/creating-custom-webhook-throwing-500-internal-error-but-curl-is-working-fine/4322/1 "2020-12-03T06:54:21Z")

</div>

Hi,

I have a slack webhook like below and its working fine both using REST client and curl;

```
curl -X POST -k -i 'https://slack.com/api/chat.postMessage?token=test_token&channel=test_channel&text=sample_text'

```

This request will publish message `sample_text` to my channel `test_channel` and can be viewed in slack app.

I tried below request from Kibana dev console;

```
POST _opendistro/_alerting/destinations
{
  "type": "custom_webhook",
  "name": "slack-destination",
  "custom_webhook": {
    "path": "api/chat.postMessage",
    "header_params": {
      "Content-Type": "application/json"
    },
    "scheme": "HTTPS",
    "port": 443,
    "query_params": {
      "token": "test_token",
      "channel": "test_channel",
      "text": "sample_text"
    },
    "host": "slack.com"
  }
}

```

when I tried this, i got 500 internal error;

```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "alerting_exception",
        "reason" : "Connection refused"
      }
    ],
    "type" : "alerting_exception",
    "reason" : "Connection refused",
    "caused_by" : {
      "type" : "exception",
      "reason" : "java.net.ConnectException: Connection refused"
    }
  },
  "status" : 500
}

```

Below is the Kibana trace;

```
Alerting - DestinationService - createDestination: { Error: [alerting_exception] Connection refused
    at respond (/kibana/node_modules/elasticsearch/src/lib/transport.js:349:15)
    at checkRespForFailure (/kibana/node_modules/elasticsearch/src/lib/transport.js:306:7)
    at HttpConnector.<anonymous> (/kibana/node_modules/elasticsearch/src/lib/connectors/http.js:173:7)
    at IncomingMessage.wrapper (/kibana/node_modules/lodash/lodash.js:4949:19)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  status: 500,
  displayName: 'InternalServerError',
  message: '[alerting_exception] Connection refused',
  path: '/_opendistro/_alerting/destinations?refresh=wait_for',
  query: {},
  body:
   { error:
      { root_cause: [Array],
        type: 'alerting_exception',
        reason: 'Connection refused',
        caused_by: [Object] },
     status: 500 },
  statusCode: 500,
  response:
   '{"error":{"root_cause":[{"type":"alerting_exception","reason":"Connection refused"}],"type":"alerting_exception","reason":"Connection refused","caused_by":{"type":"exception","reason":"java.net.ConnectException: Connection refused"}},"status":500}',
  toString: [Function],
  toJSON: [Function] }

```

Why is this happening? is there any relation with `-k` parameter of curl? Can somebody please tell me how to fix this?

Thanks.

---

<div class="post-metadata">

**Author:** ![kris](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kris/32/2208_2.png) [@kris](https://forum.opensearch.org/u/kris)\
**Post date:** [February 7, 2023, 5:17pm UTC](https://forum.opensearch.org/t/creating-custom-webhook-throwing-500-internal-error-but-curl-is-working-fine/4322/2 "2023-02-07T17:17:54Z")

</div>

Closed on February 7, 2023, 5:17pm UTC


