Users.labels: get

Requires authorization

Gets the specified label. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/gmail/v1/users/userId/labels/id

Parameters

Parameter name Value Description
Path parameters
id string The ID of the label to retrieve.
userId string The user's email address. The special value me can be used to indicate the authenticated user.

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.labels
https://www.googleapis.com/auth/gmail.metadata

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a Users.labels resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

import com.google.api.services.gmail.Gmail;
import com.google.api.services.gmail.model.Label;

import java.io.IOException;

// ...

public class MyClass {

  // ...

  /**
   * Get specified Label.
   *
   * @param service Authorized Gmail API instance.
   * @param userId User's email address. The special value "me"
   * can be used to indicate the authenticated user.
   * @param labelId ID of Label to get.
   * @throws IOException
   */
  public static void getLabel(Gmail service, String userId, String labelId)
      throws IOException {
    Label label = service.users().labels().get(userId, labelId).execute();

    System.out.println("Label " + label.getName() + " retrieved.");
    System.out.println(label.toPrettyString());
  }

  // ...
}

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Enviar comentarios sobre…

¿Necesitas ayuda? Visita nuestra página de asistencia.