getMessagesPage with $or field not working probably



  • Hello,

    I have been trying to call getMessagesPage with $or field, to get the messages sent to/from the specified profile ID. (to have a small one-to-one chat.)

    Instead, I am receiving all the messages of the current user, no matter who was the sender or receiver.

    In short: calling the API with $or, having the same response as calling it without searchCriteria at all.

    Request:

    {
        "context": {
            "searchCriteria": {
                "$or": [
                    { "message.from": "184d9950-180b-4da4-a362-f9d4a2418b81" },
                    { "message.to": "184d9950-180b-4da4-a362-f9d4a2418b81" }
                ]
            }
        }
    }
    

    In the following response, I receive three messages, when only the last one follows the rule:

    {
        "data": {
            "results": {
                "count": 3,
                "page": 1,
                "items": [
                    {
                        "message": {
                            "from": {
                                "id": "e81e35db-c349-4cee-8851-32e29538b11e",
                                "name": "Tester 1"
                            },
                            "sentAt": 1666125294637,
                            "to": [
                                "14869a2a-631b-4ea9-b241-b06a57e729f4"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "inbox"
                    },
                    {
                        "message": {
                            "from": {
                                "id": "14869a2a-631b-4ea9-b241-b06a57e729f4",
                                "name": "Tester 2"
                            },
                            "sentAt": 1666125957202,
                            "to": [
                                "e81e35db-c349-4cee-8851-32e29538b11e"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "sent"
                    },
                    {
                        "message": {
                            "from": {
                                "id": "14869a2a-631b-4ea9-b241-b06a57e729f4",
                                "name": "Tester 2"
                            },
                            "sentAt": 1666179911502,
                            "to": [
                                "184d9950-180b-4da4-a362-f9d4a2418b81"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "sent"
                    }
                ]
            }
        },
        "status": 200
    }
    

    So, am I doing something wrong here?

    Thank you very much.


  • bitHeads

    Hi Kirlos, as you can see from the response's message field, there are two elements (id and name) underneath, you need to append .id to specify the first search field for id, so change the "message.from" to "messsge.from.id" should solve this problem.


Log in to reply