The page has been marked as outdated. This generally means that the page was written for either a previous version of the package or a previous version of the underlying API(s).

Getting the organizations of a specific user

To get the public organizations of a specific user, you can use GetOrganizations method along with the username of the user. For instance to get the public organizations for my GitHub user, the code could look like below:

@using Skybrud.Social.GitHub.Models.Organizations
@using Skybrud.Social.GitHub.Responses.Organizations
@inherits WebViewPage<Skybrud.Social.GitHub.GitHubService>

@{

    // Make the request to the API
    GitHubGetOrganizationsResponse response = Model.Organizations.GetOrganizations("abjerner");

    // Get the organizations from the response body
    GitHubOrganizationItem[] body = response.Body;

    // Iterate through the organizations
    foreach (GitHubOrganizationItem org in body) {
        <p>ID: @org.Id</p>
        <p>Login: @org.Login</p>
        <br />
    }

}

The GitHub API doesn't provide a way to lookup organizations by the ID of the user.

Pagination

The returned list of organizations is paginated, meaning that you may have to request additional pages to get all organizations the user is part of. If this is the case, you can specify an instance of GitHubGetUserOrganizationsOptions with your pagination information:

@using Skybrud.Social.GitHub.Models.Organizations
@using Skybrud.Social.GitHub.Options.Organizations
@using Skybrud.Social.GitHub.Responses.Organizations
@inherits WebViewPage<Skybrud.Social.GitHub.GitHubService>

@{

    // The options for the request
    var options = new GitHubGetUserOrganizationsOptions {
        Username = "abjerner",
        Page = 2,
        PerPage = 1
    };

    // Make the request to the API
    GitHubGetOrganizationsResponse response = Model.Organizations.GetOrganizations(options);

    // Get the organizations from the response body
    GitHubOrganizationItem[] body = response.Body;

    // Iterate through the organizations
    foreach (GitHubOrganizationItem org in body) {
        <p>ID: @org.Id</p>
        <p>Login: @org.Login</p>
        <br />
    }

}

The Page property indicates the page to be returned, where 1 indicates the first page. PerPage is used to indicate the maximum amount of organizations to be returned by each page.

According to the GitHub API documentation in general, paginated results will return up to 30 items by default, while some resources allow a page size of up to 100 items.