Help Center/ Cognitive Engagement Center/ API Reference/ Web Client Access Interface Reference/ Querying Historical Messages (queryHistoryChatMessage)
Updated on 2023-09-27 GMT+08:00

Querying Historical Messages (queryHistoryChatMessage)

Scenario

This interface is invoked to query historical messages.

Method

POST

URI

https://Domain name/apiaccess/ccmessaging/queryHistoryChatMessage (For example, the domain name is service.besclouds.com.)

Request Description

Table 1 Request header parameters

No.

Parameter

Type

Mandatory or Not

Description

1

x-app-key

String

Yes

App key, which is the user ID

2

Authorization

String

Yes

Authentication field. The format is Bearer {Value of AccessToken returned by the tokenByAkSk interface}. (A space is required after Bearer.)

3

ccmessaging-token

String

Yes

Value of ccmessaging-token generated by the applyToken interface

Table 2 Request body parameters

No.

Parameter

Type

Mandatory or Not

Description

1.1

channelId

String

Yes

Channel ID

1.2

userId

String

Yes

ID of the user who sends a message through a channel. The value is a string of 1 to 32 characters.

1.3

startTime

String

No

Start time for querying historical messages

1.4

endTime

String

No

End time for querying historical messages

1.5

limit

String

Yes

Number of queried historical messages. This parameter is a pagination parameter.

1.6

offset

String

Yes

Offset. This parameter is a pagination parameter.

Response Description

  • Status code: 200
Table 3 Response body parameters

No.

Parameter

Type

Mandatory or Not

Description

1.1

messageList

Array

Yes

Queried historical messages

1.1

resultCode

String

Yes

0: success

1: failure

1.2

resultDesc

String

Yes

Return description

  • Status code: 400

    Incorrect request. Check the request path and parameters.

  • Status code: 401

    Unauthorized operation. 1. Check whether you have purchased related services. 2. Contact customer service to check the status of your account.

  • Status code: 404

    The requested content is not found. Check the request path.

  • Status code: 500

    Business failure. Check the values of parameters in the request.

Error Codes

None

Example

  • Scenario: Query historical messages.

    URL: successful request message

    Request header:

    {
    	"ccmessaging-token": "eyJjcmVhdGVUaW1lI********************************IiwiY2hhbm5lbElkIjoiMjAyMTAyMTkzMTk2ODY5NzA4In0%3D",
    	"x-app-key": "ea5c29a3-ea45-4b79-a449-2a3dbeb4c32c",
    	"Authorization": "Bearer 57042f85****************8c4e0",
    	"Content-Type": "application/json"
    }
    Request parameters:
    {
            "channelId":"202207292843442389",
            "userId":"1659490221026188522",
            "limit":"1",
            "offset":"0",
            "startTime":"1659910093000",
            "endTime":"1659938956000",
            "channel":"WEB"
    }

    Response parameters:

    {
            "messageList": [
                {
                    "id": "10113293212986888",
                    "channel": "WEB",
                    "senderNickname": "wangming77",
                    "senderAvatar": "../../image/user1.png",
                    "sendTime": 1659938956000,
                    "receiveTime": 1659938956000,
                    "controlType": "CHAT",
                    "sourceType": "USER",
                    "mediaType": "FILE",
                    "content": "diaoyu.aac,26964,fee53aad-94a0-4dc2-b7ff-fd8c2e2496f2,aac",
                    "callId": "1659938875-16806492",
                    "messageCode": "67A257B0DB5EFBC08C9F2BD612443F09BBF858570A62CCAAB8D3CE45B7C0EFD0",
                    "associationContentId": null,
                    "sendStatus": null,
                    "errorMsg": null,
                    "isForwarded": false,
                    "forwardTime": null,
                    "contentDealType": null
                 }
            ],
            "resultCode": "0",
            "resultDesc": "success"
    }