androidlinkedin-apilinkedin-j

linkedin-j not returning public profile url


I'm integrating the linkedin-j library with my Android app. I have successfully setup OAuth, and I'm able to retrieve the user's profile:

LinkedInApiClient linkedinApiClient = getLinkedinApiClient(accessToken);
Person profile = linkedinApiClient.getProfileForCurrentUser();

I'm able to get the user's first name from the API:

String firstName = profile.getFirstName();

But if I try to get the user's public profile url, I only get null:

String profileUrl = profile.getPublicProfileUrl();

Why doesn't getPublicProfileUrl work? Is this a known issue of the API?


Solution

  • I needed to add the profile url to the list of fields requested:

    Set<ProfileField> fields = new HashSet<ProfileField>();
    fields.add(ProfileField.PUBLIC_PROFILE_URL);
    linkedinApiClient.getProfileForCurrentUser(fields);