I'm trying to get the community site url, using the ConnectApi in a lightning component, with a SystemAdmin it works fine, but not with any other profile.

Here is my code

final Network myNetwork = [SELECT Id FROM Network WHERE Name ='NET NAME'];
final ConnectApi.Community  myCommunity = ConnectApi.Communities.getCommunity(myNetwork.Id);

The other profile has access to:

  • Apex REST Services
  • API Enabled

Do I need to add another permission?ßß

  • is apex class sharing or without sharing? May 2, 2019 at 9:13
  • without sharing.
    – Mo Hamada
    May 2, 2019 at 9:14

1 Answer 1


From docs mentioned here :

You will only get Ids of the Communities the running user has access to.

You have to Give that profile access to that community. In other words, you have to make that user member of that community to allow him to post.

You can add that profile in the community by going to

Setup -> Communities -> You Community -> WorkSpaces -> Adminsitation -> Member and chose the selected profile.

  • It works now. Many thanks!
    – Mo Hamada
    May 2, 2019 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .