How to get message from Mattermost API

i use React with Mattermost API
i can send message to Mattermost API but i can’t get message from Mattermost API
please help me

What API payload are you using and what error message are you getting?

I use API v4
I want to know how to receive messages in real time.

Hi, @punjan

I don’t quite get what you mean by “receive messages in real time”. Maybe you can provide some extra context around the requirement that you have here?

As you know, we have the list of available APIs in the Mattermost API that you can execute. For example, the Get posts for a channel might be the one that you are looking for.

I tried to get posts for a channel but it had to be done many times.
Or whether I used it the wrong way Now i’m trying websocket But i can’t do it
Do you have a code or suggest me about websocket?

Hello, @punjan

I see. Based on your statement here:

May I know if you would like to have some sort of dynamic message counter for every channel to show how many messages have been sent there? For example:

  • Message sent
  • Message deleted
  • Message flagged
  • Message pinned

In terms of websockets, what do you mean by using it in this scenario? Are you referring to WebSocket and how to utilize it?

I want to show the message in my chat box.
All I can do now is Message sent via the API

/ api / v4 / posts

And now I have tried to connect to websocket but there is an error
/api/v4/websocket' failed: Error during WebSocket handshake: Unexpected response code: 403


componentDidMount() {
const ws = new Websocket();
“ws://MY IPaddress/api/v4/websocket”,
"Bearer " + myToken

Thank you for answer