lima-city: Webhosting, Domains und Cloud
2 Pluspunkte 0 Minuspunkte

Auf der Website der Virola Web API (https://virola.io/web-api) stehtman kann mit Curl eine Nachricht in einen Chatroom senden. Wenn ich das mache kommt aber keine neue Message sondern ich sehe nur alle vorhandenen Messages im Chatroom.

C:\Temp>curl -k -X GET -H "Authorization: Bearer 9eee71e91cefaaac30fd0d25f540f26d" https://localhost:8080/api/v1/rooms/4/text-messages -d "{\"content\":\"Hello world\"}"
{
    "httpResponseStatusCode": 200,
    "roomId": "4",
    "textMessages": [
        {
            "created": "2025-05-05 13:26:51.775",
            "lastEditedUtcMillis": "2025-05-05 13:26:51.775",
            "lastModifiedUtcMillis": "2025-05-05 13:38:22.321",
            "priority": "Normal",
            "text": "Hi Adam",
            "textMarkupType": "TextPlain",
            "textMessageId": "5",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-05 13:38:37.933",
            "lastEditedUtcMillis": "2025-05-05 13:38:37.933",
            "lastModifiedUtcMillis": "2025-05-05 13:40:14.715",
            "priority": "Normal",
            "text": "Hi Admin, alles klar?",
            "textMarkupType": "TextPlain",
            "textMessageId": "10",
            "type": "Regular",
            "userId": "5"
        },
        {
            "created": "2025-05-05 13:40:22.295",
            "lastEditedUtcMillis": "2025-05-05 13:40:22.295",
            "lastModifiedUtcMillis": "2025-05-05 13:40:47.583",
            "priority": "Normal",
            "text": "Joa und bei dir?",
            "textMarkupType": "TextPlain",
            "textMessageId": "11",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-05 13:40:33.111",
            "lastEditedUtcMillis": "2025-05-05 13:40:33.111",
            "lastModifiedUtcMillis": "2025-05-05 13:40:47.460",
            "priority": "Normal",
            "text": "Wie gehts mit dem Spiel voran?",
            "textMarkupType": "TextPlain",
            "textMessageId": "12",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-05 13:40:53.662",
            "lastEditedUtcMillis": "2025-05-05 13:40:53.662",
            "lastModifiedUtcMillis": "2025-05-05 13:42:01.378",
            "priority": "Normal",
            "text": "Ja geht",
            "textMarkupType": "TextPlain",
            "textMessageId": "13",
            "type": "Regular",
            "userId": "5"
        },
        {
            "created": "2025-05-05 13:43:46.369",
            "lastEditedUtcMillis": "2025-05-05 13:43:46.369",
            "lastModifiedUtcMillis": "2025-05-06 06:18:14.355",
            "priority": "Normal",
            "text": "Ok",
            "textMarkupType": "TextPlain",
            "textMessageId": "14",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-05 13:43:52.898",
            "lastEditedUtcMillis": "2025-05-05 13:43:52.898",
            "lastModifiedUtcMillis": "2025-05-06 06:18:14.463",
            "priority": "Normal",
            "text": "Wann zeigst du es mir mal?",
            "textMarkupType": "TextPlain",
            "textMessageId": "15",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-05 13:45:27.235",
            "issueAssignees": "[]",
            "issueStatus": "ToVerify",
            "issueType": "Bug",
            "lastEditedUtcMillis": "2025-05-05 13:45:27.235",
            "lastModifiedUtcMillis": "2025-05-06 06:18:14.247",
            "priority": "Normal",
            "text": "Oida wos isn do los?",
            "textMarkupType": "TextPlain",
            "textMessageId": "16",
            "type": "Issue",
            "userId": "1"
        },
        {
            "created": "2025-05-07 02:26:40.688",
            "dateTimeDuration": "2025-05-07 07:00 00:30",
            "lastEditedUtcMillis": "2025-05-07 02:26:40.688",
            "lastModifiedUtcMillis": "2025-05-07 02:27:35.423",
            "priority": "Normal",
            "text": "wir machen ein meeting",
            "textMarkupType": "TextPlain",
            "textMessageId": "19",
            "type": "Meeting",
            "userId": "1"
        },
        {
            "created": "2025-05-07 02:27:49.207",
            "lastEditedUtcMillis": "2025-05-07 02:27:49.207",
            "lastModifiedUtcMillis": "2025-05-07 02:27:49.249",
            "priority": "Normal",
            "text": "...",
            "textMarkupType": "TextPlain",
            "textMessageId": "20",
            "type": "Regular",
            "userId": "1"
        },
        {
            "created": "2025-05-07 15:04:39.997",
            "lastEditedUtcMillis": "2025-05-07 15:04:39.997",
            "lastModifiedUtcMillis": "2025-05-07 15:04:39.997",
            "priority": "Normal",
            "text": "wos mocht er?",
            "textMarkupType": "TextPlain",
            "textMessageId": "21",
            "type": "Regular",
            "userId": "1"
        }
    ]
}

Wie kann ich eine neue Nachricht in einen Chatroom senden?

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Du verwendest einen GET Request!

curl -k -X GET -H "Authorization: Bearer ..." https://localhost:8080/api/v1/rooms/4/text-messages -d "{\"content\":\"Hello world\"}"

Ein GET-Request kann keine neue Nachricht senden, sondern nur vorhandene Nachrichten abrufen. Dass du dabei trotzdem -d "{\"content\":\"Hello world\"}" angegeben hast, ist irrelevant, weil curl bei -X GET den Body ignoriert bzw. viele Server ihn nicht beachten. Du musst einen POST Request machen.

curl -k -X POST \
  -H "Authorization: Bearer 9eee71e91cefaaac30fd0d25f540f26d" \
  -H "Content-Type: application/json" \
  https://localhost:8080/api/v1/rooms/4/text-messages \
  -d "{\"content\":\"Hello world\"}"
von (888 Punkte)