getSections method

Future<Object?> getSections(
  1. String title, {
  2. bool? redirect,
  3. String? acceptLanguage,
})

Get mobile-optimized HTML sections for a title.

Retrieve the latest HTML for a page title optimised for viewing with native mobile applications. Note that the output is split by sections. Stability: deprecated Here you can find more information about the endpoint deprecation. Please follow wikitech-l or mediawiki-api-announce for announcements of breaking changes.

Parameters:

  • String title (required): Page title. Use underscores instead of spaces. Use percent-encoding. Example: Main_Page.

  • bool redirect: Requests for redirect pages return HTTP 302 with a redirect target in Location header and content in the body. To get a 200 response instead, supply false to the redirect parameter.

  • String acceptLanguage: The desired language variant code for wikis where LanguageConverter is enabled. Example: sr-el for Latin transcription of the Serbian language.

Implementation

Future<Object?> getSections(
  String title, {
  bool? redirect,
  String? acceptLanguage,
}) async {
  final response = await getSectionsWithHttpInfo(
    title,
    redirect: redirect,
    acceptLanguage: acceptLanguage,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'Object',
    ) as Object;
  }
  return null;
}