Updating a message throws an error

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 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

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

Can’t figure out what am i missing here.

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

  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 are as follows:
    channel_type - group
    channel_url - sendbird_group_channel_60481280_6972eca92227288ede66684cd91678efc1b37dde
    message_id - 718626191

params:

body:

  • using the api in our code.
  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:

  1. For the sendbird sdk:
  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);
  };

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)

Here is my example showing the correct Postman request

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

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

Here’s the consoled “msg” object