Getting a status

When having an instance of MastodonHttpService, you can get a specific status via the Statuses endpoint, and then either of the GetStatus or GetStatusAsync methods.

If the request is successful, an instance of MastodonStatusResponse returned representing the overall response. The Body property then holds an instance of MastodonStatus representing the response body.

@using Skybrud.Social.Mastodon
@using Skybrud.Social.Mastodon.Exceptions
@using Skybrud.Social.Mastodon.Models.Statuses
@using Skybrud.Social.Mastodon.Responses.Statuses

@{

    // Initialize a new HTTP service (basically the API wrapper)
    MastodonHttpService mastodon = MastodonHttpService
        .CreateFromDomain("umbracocommunity.social");

    try {

        // Make the request to the Mastodon API
        MastodonStatusResponse response = await mastodon.Statuses
            .GetStatusAsync("112053849446081494");

        // Get the status from the response body
        MastodonStatus status = response.Body;

        <pre>ID: @status.Id</pre>

        <pre>Account: @status.Account.DisplayName (@status.Account.Username)</pre>

        <pre>Content: @status.Content</pre>

    } catch (MastodonHttpException ex) {

        <pre>@ex</pre>
        <pre>@ex.StatusCode</pre>
        <pre>@ex.Error</pre>
        <pre>@ex.Response.Body</pre>

        return;

    } catch (Exception ex) {

        <pre>@ex</pre>

        return;

    }

}

Notice that requests to the Mastodon API may fail, so it's recommended to wrap the request in a try/catch block.

Read more about error handling