google admin sdk – Query custom attributes from g-suite with go-ThrowExceptions

Exception or error:

I would like to make a user query from my G-Suite users about the custom attributes set up on them.

I started from the admin-sdk golang quickstart to use “FULL” projection and failed to query the custom attributes of the user.
For example it would be fine to query the standard attributes like phone or employee ID.

My custom attribute exists in the Category:Groups, Custom fields:group

        r, err := srv.Users.List().Projection("FULL").Customer("my_customer"). //MaxResults(20).
            OrderBy("email").Do()
    if err != nil {
            log.Fatalf("Unable to retrieve users in domain: %v", err)
    }

    if len(r.Users) == 0 {
            fmt.Print("No users found.\n")
    } else {
            fmt.Print("Users:\n")
            for _, u := range r.Users {
        fmt.Print("----------------------------------------------------------------\n")
                    fmt.Printf("%s (%s)\n", u.PrimaryEmail, u.Name.FullName)
        fmt.Printf("%s \n", u.CustomSchemas)
                    //fmt.Printf("%s \n", u.group)
                    //fmt.Printf("%s \n", u.group)
                    //fmt.Println(u)
            }
    }

tandard attributes (Non-editable)

How could I query ?

How to solve:

The Projection(“FULL”) has to be Projection(“full”)

        r, err := srv.Users.List().Projection("full"Projection("FULL").).Customer("my_customer"). //MaxResults(20).
            OrderBy("email").Do()
    if err != nil {
            log.Fatalf("Unable to retrieve users in domain: %v", err)
    }

    if len(r.Users) == 0 {
            fmt.Print("No users found.\n")
    } else {
            fmt.Print("Users:\n")
            for _, u := range r.Users {
        if u.CustomSchemas != nil {
                        fmt.Printf("%s (%s) %s\n", u.PrimaryEmail, u.Name.FullName, u.CustomSchemas)
        }
            }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *