Watcher error 400 webhook action

Hi!

I'm facing a problem when I try to run a watcher.

 "body": "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid JSON payload received. Unexpected token.\\nsomething\\n^\",\n    \"status\": \"INVALID_ARGUMENT\"\n  }\n}\n"

This is my actions:

 "actions": [
      {
        "id": "my_webhook",
        "type": "webhook",
        "status": "failure",
        "reason": "received [400] status code",
        "webhook": {
          "request": {
            "host": "chat.googleapis.com",
            "port": 443,
            "scheme": "https",
            "method": "post",
            "path": "v1/spaces/AAAAHS0yhM4/messages",
            "params": {
              "key": "mykey",
              "token": "mytoken"
            },
            "headers": {
              "Content-Type": "application/json"
            },
            "body": "something"
          },

Please, could some one give me a light on this? Thanks so much!

Hi @Juliana_Sabino Welcome to the community.

That webhook action looks malformed.

Here is the spec

First thing I notice is you have a "request" : { ...

Enclosing the rest of the parameters, according to the spec as far as I see that is not valid / not needed

I would fix that make sure you are using valid syntax.

Can you show your exact webhook definition (redacted credentials)

1 Like

Hey @stephenb , thank you so much!
I've followed the link you gave me and now I'm getting a 404 error. I think it's better if I open up a new topic. Thank you!

404 means you have an incorrect / not found URL..

You should be able to just use curl or postman to check the url creds etc before you try in watcher

Hi, I'm back here hehe
@stephenb, you're helping me a lot, thank you so much!

Im receiving the error 400 again.

This is my webhook actions:

"actions": {
    "my_webhook": {
      "webhook": {
        "scheme": "https",
        "host": "chat.googleapis.com",
        "port": 443,
        "method": "post",
        "path": "mypath",
        "params": {
          "key": "mykey",
          "token": "mytoken"
        },
        "headers": {},
        "body": "count: {{ctx.payload.hits.total}}"
      }
    }
  }

This is the response I'm receiving:

  "actions": [
      {
        "id": "my_webhook",
        "type": "webhook",
        "status": "failure",
        "reason": "received [400] status code",
        "webhook": {
          "request": {
            "host": "chat.googleapis.com",
            "port": 443,
            "scheme": "https",
            "method": "post",
            "path": "mypath",
            "params": {
              "key": "mykey",
              "token": "mytoken"
            },
            "body": "count: 2413"
          },
          "response": {
            "status": 400,
            "headers": {
              "date": [
                "Sun, 12 Sep 2021 19:33:28 GMT"
              ],
              "server": [
                "ESF"
              ],
              "transfer-encoding": [
                "chunked"
              ],
              "x-content-type-options": [
                "nosniff"
              ],
              "x-xss-protection": [
                "0"
              ],
              "vary": [
                "Origin",
                "X-Origin",
                "Referer"
              ],
              "x-frame-options": [
                "SAMEORIGIN"
              ],
              "content-type": [
                "application/json; charset=UTF-8"
              ],
              "cache-control": [
                "private"
              ],
              "alt-svc": [
                "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
              ]
            },
            "body": "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid JSON payload received. Unexpected token.\\ncount: 2413\\n^\",\n    \"status\": \"INVALID_ARGUMENT\"\n  }\n}\n"
          }
        }
      }
    ]
  },
  "messages": []

Do you have an idea of why this is happening? I'm having this problem one week long already :confused:

In future please don't create multiple topics on the same question, it makes it harder for people to track and help you out :slight_smile:

It's a different question @warkolm. One was 404, this one is 400.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.