+ Start a Discussion
Fota MadalinaFota Madalina 

I receive an empty list of notifications using the Connect REST API endpoint: /connect/notifications

Hello everyone,
 
I want to get all the current user's notifications to display them in a LWC component. For this, I tried to make a REST API callout from Salesforce to the same Salesforce org using Connect REST API Resources (/connect/notifications — documentation: https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_notifications_resources.htm)
I tried to make the callout using first Workbench, then an apex class, but I always get the same result, an empty list of notifications. The current user has both custom and standard notifications, so I don't understand why I always get an empty list.
 
Does anyone have any idea why I receive an empty list of notifications?
User-added imageUser-added image
Maharajan CMaharajan C
Hi Fota,

Even it tried the same in workbecnch but it's not coming. May be due to Workbench connected apps...we are facing this restriction.

But when i am running the below code in developer console Anonymous window am getting the connect nottification in debug logs. So you can try the below code in you LWC Component to fetch the Connect Notifications.
 
String sfdcURL = URL.getOrgDomainUrl().toExternalForm(); 
String restAPIURL = sfdcURL + '/services/data/v51.0/connect/notifications';
HttpRequest httpRequest = new HttpRequest();  

httpRequest.setMethod('GET');

httpRequest.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
httpRequest.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID()); 
httpRequest.setEndpoint(restAPIURL);  
String response = '';
try {  
    Http http = new Http();   
    HttpResponse httpResponse = http.send(httpRequest);  
    if (httpResponse.getStatusCode() == 200 ) {  
        response = JSON.serializePretty( JSON.deserializeUntyped(httpResponse.getBody()) );  
   		system.debug(' Connect Notifications---> ' + response);
    }
} catch( System.Exception e) {  
    System.debug('ERROR: '+ e);  
}

Thanks,
Maharajan.C

 
Fota MadalinaFota Madalina
Hi Maharajan C,
The code given by you works but only returns custom notifications (the second notification in my screenshot above). Do you know any way to get standard notifications as well?
bhfgdng fgdhbgfbhfgdng fgdhbgf
This issue is now very commen you need to learn some basic steps about REST API endpoint just visit here (https://lnd.achievegroup.asia/softskills) and learn about it.
covore7855 covore7855covore7855 covore7855
World Live News (https://www.worldlive.news/" style="color:blue; text-decoration:underline) Today's Top International News Headlines, news on politics, Business, Crime, Sports and Current World News: Get Latest and breaking information from World.
 
fdsgfd ggfdhbfdsgfd ggfdhb
The main thing that we all know is the endpoints determination in a correct way you can see here (https://www.fishingverge.com/) the details about it.
fdsgvf vdsgvfdsgvf vdsgv
This is exactly the same issue that I faced bit you need this code (https://saboglob.com/) because it helped me to solve this issue ina very authentic way.