+ Start a Discussion
Charles LangleyCharles Langley 

Trailhead Project Build an Instant Notification App - Subscribe to Platform Event


Hello All, 

 I have a question. I am attempting to do the Build an Instant Notification App project. I am trying to add some code in the Apex Class to get the SessionId as instructed in the Subscribe to Platform Event.

Here is the code:
 
@AuraEnabled public static String getSessionId() { return UserInfo.getSessionId(); }

In creating the method and trying to save it, I get the following error under the Developer Console:

unexpected token: 'String'

Can anyone please help as I don't understand why this error would come up. Thank you in advance.
Best Answer chosen by Charles Langley
NagendraNagendra (Salesforce Developers) 
Hi Charles,

Sorry for this issue you are encountering.

I have tried the same in my developer org and everything is working fine for me.For your reference please find the below screenshot where I was successfully able to save the class.
User-added image

May I suggest you please give a try by clearing all the cookies and cache in the browser you are logged in which should help.

Still, if the problem persists log out of all the accounts and give a try by attempting the same in a brand new developer org with a different browser which should probably do the trick for you.

Hope this helps.

Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Charles,

Sorry for this issue you are encountering.

I have tried the same in my developer org and everything is working fine for me.For your reference please find the below screenshot where I was successfully able to save the class.
User-added image

May I suggest you please give a try by clearing all the cookies and cache in the browser you are logged in which should help.

Still, if the problem persists log out of all the accounts and give a try by attempting the same in a brand new developer org with a different browser which should probably do the trick for you.

Hope this helps.

Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
This was selected as the best answer
Charles LangleyCharles Langley
Issue has been resolved. Thank you so much Nagendra. What you suggested worked.
Patrick McClellanPatrick McClellan
The issue happened to me as well because, like the other code snippets, I copied the code from the assignment and replaced the entire contents of the class. Instead, I just have inserted the code, with the public class declaration, like this:
public class NotificationController {

@AuraEnabled
public static String getSessionId() {
  return UserInfo.getSessionId();
}
}

 
Laura ThomasLaura Thomas
Thank you, Patrick!  Copy and paste gets me again!!!