Retrieve notes and attachments

The following sample shows how to retrieve a note and its attachment:


Call with the name of the attachment download and the alt=media URL parameter. The alt=media URL parameter tells the server that a download of content is being requested.

To get the name of the attachment, you must first retrieve the note.


 * Gets and downloads the attachment of a note.
 * @param note The note whose attachment will be downloaded.
 * @throws IOException
private void getNoteAttachment(Note note) throws IOException {
  // First call is to get the attachment resources on the note.
  List<Attachment> attachments =

  if (!attachments.isEmpty()) {
    Attachment attachment = attachments.get(0);
    String mimeType = attachment.getMimeType().get(0);
    // A second call is required in order to download the attachment with the specified mimeType.
    OutputStream outputStream = new FileOutputStream("attachmentFile." + mimeType.split("/")[1]);