API Notification Endpoint Search Parameters Not Working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • josbourn
    Junior Member
    • May 2025
    • 1

    #1

    API Notification Endpoint Search Parameters Not Working

    I searched a bit but couldn't find an answer, so apologies if this is a duplicate or has been answered before.

    I am trying to make a custom version of the popup-notifications that have a timeout option and the ability to use the JavaScript Notification API (Any mention after this to API refers to the EspoCRM API, not the JS Notification API). This has gone fine and seems to work.

    Where I am stumbling a bit is getting the collection of unread notifications on page load. I am using the "Notification/action/notReadCount" request to get the total unread count, which works fine. The main issue is getting the collection of notifications that are not read. The notification controller automatically marks any fetched entries as read, which isn't ideal. I'm trying to avoid overriding the default notification controller, so I don't really want to change that behavior directly. In my efforts to figure out a way around this, I tried making a request to get the notifications as JSON (using "Espo.Ajax.getRequest('Notification')") with a "where" selector to get only entries that do not have "read: true". While doing this, I noticed that the API endpoint for the Notification entity does not care about any "where" selectors, it only takes the offset and maxSize params. Is this something that would need the Notification controller to be changed to actually use the "where" selector param?

    If anyone has any better ideas to check for unread notifications, please feel free to let me know. I'm open to ideas.

    Here is the request copied from Postman (minus the base API URL segment). I have the maxSize set to 1 to make it easier to see the result:
    Code:
    Notification/action/list?maxSize=1&whereGroup[0][type]=isFalse&whereGroup[0][attribute]=isRead&attributeSelect=id,deleted,number
Working...