Search code examples
javascriptlinkedin-apilinkedin-jsapi

Linkedin Api how to get groups details through people search


I need to get the groups of an user,

IN.API.Raw("/people-search:(people:(id,first-name,last-name,email-address,industry,summary,num-connections,headline,group-memberships:(group:(id)))?first-name=ramesh&last-name=kotha&count="+25).result(function(result, metadata) {
//got the details here
}

when i use result.values[0].person.groupMembership.group.id it is saying undefined. How to get the groups of a user.


Solution

  • Nesting the requests to build the objects would work:

    IN.API.Raw("/people-search:(people:(id,first-name,last-name,email-address,industry,summary‌,group-memberships,num-connections,headline))?first-name=ramesh&last‌​-name=kotha&count="+25)
    .result(function(result, metadata) {
         console.log(result);
    
         for(person in result.people.values){
            console.log(person);
           IN.API.Raw()
              .url("/people/" + result.people.values[person].id + "/group-memberships:(group:(id,name),membership-state)")
    
             .result(function(result, metadata){
    
                console.log(result);
              });
    
        }
    
    
    })