Repository: ansible-collections/community.general

Issue:
community.general.slack: charset missing from content-type leading to warning every time
### Summary

The `community.general.slack` module should define the charset in the `Content-type` header. Otherwise the module will always return a warning from Slack about `missing_charset`.

### Issue Type

Bug Report

### Component Name

slack

### Ansible Version

```console (paste below)
$ ansible --version
ansible [core 2.11.7]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/x/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/venv/lib64/python3.6/site-packages/ansible
  ansible collection location = /home/x/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/venv/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.2
  libyaml = True

```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 4.1.0
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
(not relevant)
```


### OS / Environment

EL7

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: Slack message
  community.general.slack:
    channel: somechannel
    token: sometoken
    username: someuser
    msg: hello world
```


### Expected Results

Expect no warnings from the Slack API call.

### Actual Results

```console (paste below)
[...]
    ok: true
    response_metadata:
      warnings:
      - missing_charset
    ts: '1640000150.000000'
    warning: missing_charset
[...]
```

There is always a warning about `missing_charset` in the module output.

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/notification/slack.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/notification/slack.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @ramondelafuente
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py
--- a/plugins/modules/notification/slack.py
+++ b/plugins/modules/notification/slack.py
@@ -346,7 +346,7 @@ def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_e
 
 def get_slack_message(module, token, channel, ts):
     headers = {
-        'Content-Type': 'application/json',
+        'Content-Type': 'application/json; charset=UTF-8',
         'Accept': 'application/json',
         'Authorization': 'Bearer ' + token
     }
@@ -383,7 +383,7 @@ def do_notify_slack(module, domain, token, payload):
         slack_uri = OLD_SLACK_INCOMING_WEBHOOK % (domain, token)
 
     headers = {
-        'Content-Type': 'application/json',
+        'Content-Type': 'application/json; charset=UTF-8',
         'Accept': 'application/json',
     }
     if use_webapi:


Test patch: