# Updating a message throws an error

**URL:** <https://community.sendbird.com/t/updating-a-message-throws-an-error/7390>\
**Category:** Miscellaneous\
**Created:** [May 23, 2023, 8:39am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390 "2023-05-23T08:39:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [May 23, 2023, 8:39am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390/1 "2023-05-23T08:39:33Z")

</div>

I want to update a message and when trying to do so it gives me an error.

1. when using sendbird sdk [https://sendbird.com/docs/chat/v4/javascript/message/managing-a-message/update-a-message](https://sendbird.com/docs/chat/v4/javascript/message/managing-a-message/update-a-message) to update a message, it gives me a sendbird exception: Invalid parameters.

2. when trying to update it through platform api. It gives me a platform api error. [https://sendbird.com/docs/chat/v3/platform-api/message/messaging-basics/update-a-message](https://sendbird.com/docs/chat/v3/platform-api/message/messaging-basics/update-a-message)

```auto
{
    "error": true,
    "message": "Platform API Error",
    "code": 400404
}

```

Can’t figure out what am i missing here.

---

<div class="post-metadata">

**Author:** ![Ian](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ian/32/2077_2.png) [@Ian](https://community.sendbird.com/u/Ian)\
**Post date:** [May 23, 2023, 8:44am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390/2 "2023-05-23T08:44:48Z")

</div>

Hello @Namrata_Jain, and welcome to the Sendbird community.

Please provide your JavaScript code showing how you update the message and your API request/body. The `400404` error from the platform API means that the request URL is not correct.

For reference: [Error codes | Chat Platform API | Sendbird Docs](https://docs.sendbird.com/docs/chat/v3/platform-api/error-codes#2-error-codes)

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [May 23, 2023, 9:32am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390/4 "2023-05-23T09:32:05Z")

</div>

1. For the platform api:  
sending put request to endpoint:

- using postman  
`https://api-F53DF97C-E104-4603-A396-8FC7DB7BB37A.sendbird.com/v3/:channel_type/:channel_url/messages/:message_id`

params:

 ![Screenshot 2023-05-23 at 2.43.45 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/7/776912bf28fa568b861484f267f02889457129a6.png)

body:

 ![Screenshot 2023-05-23 at 2.45.05 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/5/5aba34f2f7287e02308a822bc12a308396b0d9eb.png)

- using the api in our code.

```auto
  const handleHideOgMetaData = async (msg) => {
    try {
      const res = await sbAxios.put(
        `${ticket?.channel?.channel_type}/${ticket?.channelUrl}/messages/${msg?.messageId}`,
        {
          message_type: msg?.messageType,
          data: JSON.stringify({ hideOGMetaData: true }),
        },
        {
          headers: {
            "Api-Token": "REMOVED",
          },
        }
      );
      console.log("res", res);
    } catch (error) {
      console.log("e", error);
    }
  };

```

here’s the error that i get:

 ![Screenshot 2023-05-23 at 2.57.43 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/6/6defff024e7c2dcce59751ee5c74a6ff19cb233f.png)

1. For the sendbird sdk:

```auto
  const handleHideOgMetaData = async (msg) => {
    const params = {
      message: msg?.message,
      customType: message?.customType,
      data: JSON.stringify({ hideOgMetaData: true }),
    };
    const updatedMessage = await ticket.channel.updateUserMessage(
      msg?.messageId,
      params
    );
    console.log("updatedMessage", updatedMessage);
  };

```

 ![Screenshot 2023-05-23 at 3.01.26 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/2/22d016b20b1c7cec9db103d29bf10f5ccfe640a3.png)

---

<div class="post-metadata">

**Author:** ![Ian](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ian/32/2077_2.png) [@Ian](https://community.sendbird.com/u/Ian)\
**Post date:** [May 24, 2023, 5:09am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390/5 "2023-05-24T05:09:41Z")

</div>

> [@Namrata\_Jain](#):
>
> here’s the error that i get:

Please check the `url` field in this error message for your Axios. You are returning `undefined/sendbird_group_channel_60481280_6972eca92227288ede66684cd91678efc1b37ddel` when it should be `group_channels`. You should print `ticket?.channel?.channel_type` to the console to validate that you are receiving the correct value (should be `group_channels`).

In your Postman request, the `message_type` is incorrect. This should not be `user`, this should be `MESG` (please refer to the following docs page: [Update a message | Chat Platform API | Sendbird Docs](https://docs.sendbird.com/docs/chat/v3/platform-api/message/messaging-basics/update-a-message#4-list-of-properties-for-updating-a-text-message))

Here is my example showing the correct Postman request

```auto
curl --location --request PUT 'https://api-us-3.sendbird.com/v3/group_channels/sendbird_group_channel_186227241_a10afa23dba8177de3e627fa67a4af9e10ad3782/messages/7225435387' \
--header 'Content-Type: application/json' \
--header 'api-token: REMOVED' \
--data '{
    "message_type": "MESG",
    "data": "{ hideOGMetaData: true }"
}'

```

The response from the Platform API is 200 OK with the correct `message_type`

 ![Screenshot 2023-05-24 at 13.58.56](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/d/d2a2c844ba4b54af17a5b8f13ca13b64fd12b6ff.jpeg)

For the Sendbird SDK, could you please `console.log(msg)` and post the object?

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [May 24, 2023, 5:47am UTC](https://community.sendbird.com/t/updating-a-message-throws-an-error/7390/6 "2023-05-24T05:47:45Z")

</div>

Here’s the consoled “msg” object

 ![Screenshot 2023-05-24 at 11.16.04 AM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/1/17b38a2b83f43e3b58b276f9d68ac40d00e2369c.png)
