1
votes

I'm implementing a LinkedIn API reader to get the summary and skills of the user. The OAuth2 authentication process works fine, but I get stucked here, when I try to retrieve the profile object:

public void OAuth2(string code, string state, string error, string error_description)
{
    // create a configuration object
    var config = new LinkedInApiConfiguration("api-key", "api-secret-code");

    // get the APIs client
    var api = new LinkedInApi(config);

    if(!string.IsNullOrEmpty(error) || !string.IsNullOrEmpty(error_description))
    {
        // handle error and error_description
    }
    else
    {
        var redirectUrl = "http://mywebsite/LinkedIn/OAuth2";
        var userToken = api.OAuth2.GetAccessToken(code, redirectUrl);


        var user = new UserAuthorization(userToken.AccessToken);
        var profile = api.Profiles.GetMyProfile(user); //Here I don't know what to pass as acceptLanguages and FieldSelector!!
    }    
}

There is no argument given that corresponds to the required formal parameter 'acceptLanguages' of 'ProfilesApi.GetMyProfile(UserAuthorization, string[], FieldSelector)'

I'm trying to understand from Sparkle.LinkedIn Api project but there is no documentation.

I want to retrieve only the summary and skills fields.

1

1 Answers

1
votes

solved by creating a simple array with language codes, and a FIeldSelector variable:

var acceptLanguages = new string[] { "it-IT","en-US", };
var fields = FieldSelector.For<Person>()
            .WithId()
            .WithFirstName()
            .WithLastName()
            .WithFormattedName()
            .WithEmailAddress()
            .WithHeadline()
            .WithLocationName()
            .WithLocationCountryCode()
            .WithPictureUrl()
            .WithPublicProfileUrl()
            .WithSummary();
Person profile = api.Profiles.GetMyProfile(user,acceptLanguages,fields);