0

I am using linkedin-j.jar to get the get the LinkedIn Profile using getProfileById method but I am not able to fetch the Connections which comes from getConnection() method, it is always return null.

Can any one help me to come out this issue, below are the code snippet

Set<ProfileField> connectionFields = EnumSet.of(ProfileField.FIRST_NAME, ProfileField.LAST_NAME,ProfileField.CONNECTIONS)

Person person = client.methgetProfileById("id",connectionFields);
Connections conn = person.getConnections();

conn variable is coming as null.

Also I wanted to know that, why it is coming null.

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58

1 Answers1

1

Please check below code :

 final LinkedInApiClientFactory factory = LinkedInApiClientFactory
            .newInstance(BFF_CONSUMER_KEY, BFF_CONSUMER_SECRET);
            final LinkedInApiClient client = factory
            .createLinkedInApiClient(accessToken);

  Set<ProfileField> fields = EnumSet.of(ProfileField.ID,
          ProfileField.FIRST_NAME, ProfileField.LAST_NAME,ProfileField.CONNECTIONS);

  Person profile = client.getProfileForCurrentUser(fields);   
  Person person = client.getProfileById(profile.getId(),fields);
  Connections conn = person.getConnections();
Nilesh Mistry
  • 339
  • 2
  • 13