Abby W
Abby W

Reputation: 61

I keep receiving an empty message error when trying to post a webhook

This is my first time using Discord embeds, let alone, making a webhook. Having a little bit of trouble trying to figure out what I'm doing wrong. Hopefully someone can help!

When I try to send an embed with a message with this code:

{
  "username": "Official Discord Servers",
  "avatar_url": "https://imgur.com/a/Cl3zspb",
  "embeds": [{
    "description": "Here is a list of official Discord servers maintained by our State. Note that most of these servers may restrict full access to those who are members of their respective departments:",
    "color": 16007990,
    "fields": [
      {
        "name": "State of Atoll",
        "value": "[Discord Server](https://discord.gg/5KKgb2z)"
      },
      {
        "name": "Atoll Law Enforcement Training Academy",
        "value": "[Discord Server](https://discord.gg/GJnbavz)"
      },
      {
        "name": "Atoll Department of Homeland Security",
        "value": "[Discord Server](https://discord.gg/acnPFa7)"
      },
      {
        "name": "Palm County Sheriff's Office",
        "value": "[Discord Server](https://discord.gg/uYFANDs)"
      },
      {
        "name": "Atoll State Police",
        "value": "[Discord Server](https://discord.gg/WNHKtra)"
      },
      {
        "name": "Atoll Department of Corrections",
        "value": "[Discord Server](https://discord.gg/VbFew9s)"
      },
      {
        "name": "Atoll National Guard",
        "value": "[Discord Server](https://discord.gg/6zE9HyW)"
  }]
}

I get this error:

{ "code": 50006, "message": "Cannot send an empty message" }

Upvotes: 6

Views: 12767

Answers (4)

Balasubramanian S
Balasubramanian S

Reputation: 1433

In my case, I was sending a plain text directly instead of JSON in the request. Then when I changed the message to the below it worked.

{content: "This is the message"}

If you are sending embeds, you can still keep the content set to null.

Upvotes: 0

Vaibhav J
Vaibhav J

Reputation: 1334

The JSON referred in the question cannot be parsed, it is not properly formed, it is missing closing brackets. Please find last set of }] brackets in my answer below, try this,

{
  "username": "Official Discord Servers",
  "avatar_url": "https://imgur.com/a/Cl3zspb",
  "embeds": [{
    "description": "Here is a list of official Discord servers maintained by our State. Note that most of these servers may restrict full access to those who are members of their respective departments:",
    "color": 16007990,
    "fields": [
      {
        "name": "State of Atoll",
        "value": "[Discord Server](https://discord.gg/5KKgb2z)"
      },
      {
        "name": "Atoll Law Enforcement Training Academy",
        "value": "[Discord Server](https://discord.gg/GJnbavz)"
      },
      {
        "name": "Atoll Department of Homeland Security",
        "value": "[Discord Server](https://discord.gg/acnPFa7)"
      },
      {
        "name": "Palm County Sheriff's Office",
        "value": "[Discord Server](https://discord.gg/uYFANDs)"
      },
      {
        "name": "Atoll State Police",
        "value": "[Discord Server](https://discord.gg/WNHKtra)"
      },
      {
        "name": "Atoll Department of Corrections",
        "value": "[Discord Server](https://discord.gg/VbFew9s)"
      },
      {
        "name": "Atoll National Guard",
        "value": "[Discord Server](https://discord.gg/6zE9HyW)"
      }]
    }]
}

Upvotes: 0

misticos
misticos

Reputation: 787

It requires header Content-Type with value application/json. Also try setting content field.

Your issue is invalid JSON, so try using JSON validator

Upvotes: 5

Ghonima
Ghonima

Reputation: 3082

You need to send "content" as a key value pair containing the content of the message being sent.

"content": "Just testing webhooks"

Upvotes: 8

Related Questions