getMessagesPage with $or field not working probably
-
Hello,
I have been trying to call
getMessagesPagewith$orfield, 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 withoutsearchCriteriaat 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.
-
Hi Kirlos, as you can see from the response's
messagefield, there are two elements (idandname) underneath, you need to append.idto specify the first search field forid, so change the"message.from"to"messsge.from.id"should solve this problem.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login