# POST Send a chat message return Bad request

**URL:** <https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730>\
**Category:** API and Webhooks\
**Created:** [July 16, 2024, 5:46am UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730 "2024-07-16T05:46:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![igorsaints](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/igorsaints/32/61477_2.png) [@igorsaints](https://devforum.zoom.us/u/igorsaints)\
**Post date:** [July 16, 2024, 5:46am UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/1 "2024-07-16T05:46:15Z")

</div>

```
public static async Task<string> SendMessageToChannel(string message)
{
    string token = (await GetToken()).ToString();
    if (token != string.Empty)
    {
        string channelId = "bf157781716f42d19e151a7cf7c63f85";
        var builder = WebApplication.CreateBuilder();
        var configuration = builder.Configuration;
        HttpClient _client = new HttpClient();
        _client.DefaultRequestHeaders.Accept.Clear();
        _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        UriBuilder _uri = new UriBuilder("https://api.zoom.us/v2/chat/users/P6kvmalrQMK9pceHN8RMYw/messages");
        try
        {
            string json1 = "{\"message\":\"" + message + "\",\"to_channel\":\"" + channelId + "\"}";
            string json2 = $@"{{
              ""message"": ""{message}"",
              ""at_items"": [
                {{
                  ""at_contact"": ""<email>"",
                  ""at_type"": 1,
                  ""end_position"": ""<integer>"",
                  ""start_position"": ""<integer>""
                }},
                {{
                  ""at_contact"": ""<email>"",
                  ""at_type"": 1,
                  ""end_position"": ""<integer>"",
                  ""start_position"": ""<integer>""
                }}
              ],
              ""rich_text"": [
                {{
                  ""start_position"": ""<integer>"",
                  ""end_position"": ""<integer>"",
                  ""format_type"": ""Italic"",
                  ""format_attr"": ""<string>""
                }},
                {{
                  ""start_position"": ""<integer>"",
                  ""end_position"": ""<integer>"",
                  ""format_type"": ""LeftIndent"",
                  ""format_attr"": ""<string>""
                }}
              ],
              ""file_ids"": [
                ""<string>"",
                ""<string>""
              ],
              ""reply_main_message_id"": ""<string>"",
              ""to_channel"": ""{channelId}"",
              ""to_contact"": ""<email>""
            }}";
            var request = new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                RequestUri = _uri.Uri,
                Content = new StringContent(
                    json1,
                    Encoding.UTF8,
                    MediaTypeNames.Application.Json),
            };
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

            var response = await _client.SendAsync(request).ConfigureAwait(false);
            response.EnsureSuccessStatusCode();

            var responseBody = await response.Content.ReadAsStringAsync();
            //var x= JsonDocument.Parse(responseBody).RootElement.GetProperty("access_token").ToString();
            return responseBody;
        }
        catch (Exception e)
        {
            return string.Empty;
        }
    }
    return string.Empty;
}

```

Can you help me with this code, as it only returns Bad Request. I’ve already used content json1 and json2, it generates the same error. Which fields are mandatory, do they have a correct sequence?

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [July 22, 2024, 8:08pm UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/2 "2024-07-22T20:08:33Z")

</div>

Hi @igorsaints  
Thanks for reaching out to us!  
Have you been able to troubleshoot this on your end?

---

<div class="post-metadata">

**Author:** ![igorsaints](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/igorsaints/32/61477_2.png) [@igorsaints](https://devforum.zoom.us/u/igorsaints)\
**Post date:** [July 29, 2024, 8:15am UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/3 "2024-07-29T08:15:40Z")

</div>

I managed to do it, but I can’t get the message reply event from a chat.

---

<div class="post-metadata">

**Author:** ![igorsaints](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/igorsaints/32/61477_2.png) [@igorsaints](https://devforum.zoom.us/u/igorsaints)\
**Post date:** [July 29, 2024, 9:02am UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/4 "2024-07-29T09:02:23Z")

</div>

How do I add the chat message read and write scope and how do I trigger a chat message replied in a specific channel. I need to take a message forwarded in a channel and send it to an API.

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 1, 2024, 7:10pm UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/5 "2024-08-01T19:10:55Z")

</div>

Hi @igorsaints  
Here you will find all the available endpoints for Team Chat

> **[Zoom Team Chat API](https://developers.zoom.us/docs/api/rest/reference/chat/methods/#overview)**
>
> API Reference for /docs/api/rest/reference/chat/methods

And the webhooks as well

> **[Zoom API Events - Team Chat](https://developers.zoom.us/docs/api/rest/reference/chat/events/#overview)**
>
> API Reference for /docs/api/rest/reference/chat/events

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [June 4, 2025, 9:21am UTC](https://devforum.zoom.us/t/post-send-a-chat-message-return-bad-request/113730/6 "2025-06-04T09:21:33Z")

</div>

Closed on June 4, 2025, 9:21am UTC

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