0
votes

I'm trying to get the summary and Skills fields from the LinkedIn API using Sparkle.LinkedIn. Everything works fine, I can read Headline, FirstName and LastName fields, but Skills, Summary, Industry, DateOfBirth and other fields are always empty even if the LinkedIn profile has them for sure.

Here is the code I'm using when the user has already been authenticated and I have the token:

var fields = FieldSelector.For<Person>()
    .WithId()
    .WithFirstName()
    .WithLastName()
    .WithEmailAddress()
    .WithHeadline()
    .WithPictureUrl()
    .WithPublicProfileUrl()
    .WithSummary()
    .WithIndustry()
    .WithDateOfBirth()
    .WithSkills();

var config = new LinkedInApiConfiguration("api-key", "key-secret");    
var api = new LinkedInApi(config);    
if(!string.IsNullOrEmpty(error) || !string.IsNullOrEmpty(error_description))
{
    Response.Write(error + "<br/>" + error_description);
}
else
{
    var redirectUrl = "my-redirect-url";
    var userToken = api.OAuth2.GetAccessToken(code, redirectUrl);    
    var acceptLanguages = new string[] { "it-IT","en-US", };

    var user = new UserAuthorization(userToken.AccessToken);
    Person profile = api.Profiles.GetMyProfile(user,acceptLanguages,fields);
    Response.Write(profile.Headline + "<br/>");
    Response.Write(profile.Summary + "<br/>"); //always empty
    Response.Write(profile.Industry + "<br/>"); //always empty
    Response.Write(profile.PictureUrl + "<br/>");  //always empty
    if(profile.Skills!=null)  //always null
    {
       foreach (var sk in profile.Skills.Skill)
       {
           Response.Write(sk.SkillName.Name + "<br/>");
       }
    }
    Response.Write(profile.Lastname + "<br/>");
    Response.Write(profile.DateOfBirth.Year + "<br/>"); //always empty

}

How can I retrieve also the summary and skills fields?

1
The code looks good. It appears to be a nuance of LinkedIn, perhaps authorization as Achille suggests.N-ate
Searching in Internet seems there is a big undocumented change in the Linked API, as they are closing the access to most of the fields for the open API. Only big companies partners of LinkedIn can access it. This is what I've read, if someone could confirm it,Giox

1 Answers

0
votes

Unfortunately I can't comment your post, but what I can tell is that this of course isn't a logic order error. Looking at it really quickly, one thing I would try is to replace everything in the field selector with .WithAllFields().

Also one thing I found here How to get summary of connections for LinkedIn API using omniauth-linkedin gem, is that you might need more permission than what you have now (I've never used this api, so im not sure)