Since you mentioned that you were able to access Mattermost through the web browser, I would like to understand a little better the address you used to access it. Were you accessing it through http://localhost:8065 itself or rather https://127.0.0.1:8065?
Were you trying to run the curl command from the same machine that you deployed Mattermost on? Can you also provide some screen shots on how you try to utilize the API on Postman?
Lastly, I would like to know if you are able to use a simple cURL command to send a message to a room via terminal in the machine you deployed Mattermost on:
curl --location --request POST "http://localhost:8066/api/v4/posts" --header "Authorization: Bearer <token>" --header "Content-Type: application/json" --header "X-Requested-With: XMLHttpRequest" --data "{\"message\":\"This is a new test\", \"channel_id\":\"<channel_id>\"}"
The issue is solved by removing the port number in the api route.
Based on the documentation I thought that the port number 8065 was necessary, but it was not, so once we took it out, we were able to access the api using postman.