diff --git a/discord_webhook/async_webhook.py b/discord_webhook/async_webhook.py index 250c658..2062669 100644 --- a/discord_webhook/async_webhook.py +++ b/discord_webhook/async_webhook.py @@ -116,8 +116,9 @@ async def execute(self, remove_embeds=False) -> "httpx.Response": if remove_embeds: self.remove_embeds() self.remove_files(clear_attachments=False) - if webhook_id := json.loads(response.content.decode("utf-8")).get("id"): - self.id = webhook_id + if response.content: # don't parse if response has no content (204 response code) + if webhook_id := json.loads(response.content.decode("utf-8")).get("id"): + self.id = webhook_id return response async def edit(self) -> "httpx.Response": diff --git a/discord_webhook/webhook.py b/discord_webhook/webhook.py index 8291814..6fae707 100644 --- a/discord_webhook/webhook.py +++ b/discord_webhook/webhook.py @@ -470,11 +470,12 @@ def execute(self, remove_embeds: bool = False) -> "requests.Response": if remove_embeds: self.remove_embeds() self.remove_files(clear_attachments=False) - response_content = json.loads(response.content.decode("utf-8")) - if webhook_id := response_content.get("id"): - self.id = webhook_id - if attachments := response_content.get("attachments"): - self.attachments = attachments + if response.content: # don't parse if response has no content (204 response code) + response_content = json.loads(response.content.decode("utf-8")) + if webhook_id := response_content.get("id"): + self.id = webhook_id + if attachments := response_content.get("attachments"): + self.attachments = attachments return response def edit(self) -> "requests.Response":