NowAttachmentService interface - Android

concept australia Updated Sep 10, 2026 4 min read NowAttachServiceAndroidInterface.md
Raw file servicenow.com

The NowAttachmentService interface provides functions that enable the manipulation of file attachments and their associated metadata.

Name Type Description
configuration NowServiceConfiguration Configuration to associate with the service.

Parent Topic:Mobile SDK - Android

NowAttachmentService - attachment(sysId: String, validateAttachment: Boolean = true)

Retrieves the attachment with the specified sys_id and optionally validates the attachment by comparing the computed hash of the attachment to the expected hash.

Name

Type

Description

sysId

String

Sys_id of the attachment to retrieve. This is the sys_id for the attachment on your ServiceNow instance.

validateAttachment

Boolean

Flag that indicates whether to validate the attachment.

Valid values:

  • true: Validate the attachment.
  • false: Do not validate the attachment.

Default: true

|Type|Description| |----|-----------| |[Call](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/CallAndroidInterface.md)<[NowAttachment](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentAndroidAPI.md)>|NowAttachment object that contains the requested attachment.|
JavaScript
fun getAttachment(sysId: String, isValidateAttachment: Boolean) {   val call = attachmentService.attachment(sysId, isValidateAttachment)   call.enqueue(     { response ->       val attachment: NowAttachment? = response.body     },       { nowDataError -> handleError(nowDataError) }   ) }

NowAttachmentService - attachmentMetadata(sysId: String)

Retrieves the metadata for the attachment associated with the specified sys_id.

Name Type Description
sysId String Sys_id of the attachment whose metadata you want to retrieve.
Type Description
Call​<NowAttachmentMetadata> Object that contains the metadata for the specified attachment.
JavaScript
fun fetchMetadata(sysId: String) {   val call = attachmentService.attachmentMetadata(sysId)   call.enqueue(    { response ->       val metadata: NowAttachmentMetadata? = response.body     },    { nowDataError -> handleError(nowDataError) }   )}

NowAttachmentService - attachmentMetadata(filter: Filter? = null, limit: Int? = null)

Retrieves the metadata for all the attachments that meet the specified criteria.

Name

Type

Description

filter

Filter

Optional. Query string to use to filter the attachments whose metadata to return.Default: null - Returns metadata for all available attachments. Takes into consideration the limit parameter.

limit

Integer

Optional. Maximum number of attachment file's metadata to return.Default: null - Returns all metadata that meets the filter parameter specifications.

|Type|Description| |----|-----------| |[Call](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/CallAndroidInterface.md)<[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/)​<[NowAttachmentMetadata](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentMetadataAndroidAPI.md)>>|List of objects that contain the metadata for the matching attachments.|
JavaScript
fun fetchMultipleMetadata(filterQuery: String, limit: Int) {   val call = attachmentService.attachmentMetadata(Filter(filterQuery), limit)   call.enqueue(     { response ->       val metadataList: List<NowAttachmentMetadata>? = response.body     },    { nowDataError -> handleError(nowDataError) }   )}

NowAttachmentService - attachmentMetadataPaginator(filter: Filter? = null, limit: Int? = null)

Retrieves the metadata for all the attachments that meet the specified criteria and creates a paginator for iterating through the pages of the returned metadata.

You can use this paginator to navigate through the returned metadata, performing navigation operations such as fetching the first, last, previous, or next page, or checking whether there is next or previous page.

Name

Type

Description

filter

Filter

Optional. Query string to use to filter the attachments whose metadata to return.Default: null - Returns metadata for all available attachments. Takes into consideration the limit parameter.

limit

Integer

Optional. Maximum number of attachment file's metadata to return.Default: null - Returns all metadata that meets the filter parameter specifications.

Type

Description

Paginator​<NowAttachmentMetadata>

Success: Paginator object along with the specified pages of metadata. Failure: NowDataError object.

The following code example shows how to call this function.
CSS
suspend fun createAttachmentMetadataPaginator() {  val filterQuery: String = "content_type=text/plain"  val filter = filterQuery.let(::Filter)  val limit = 10  val paginator = nowServiceManager.getNowAttachmentService()?.attachmentMetadataPaginator(filter, limit)    ?.observe(object : PaginatorCallBack<NowAttachmentMetadata> {      override fun onFailure(e: NowDataError) {        handleError(e)      }
      override fun onSuccess(response: Response<List<NowAttachmentMetadata>>) {        handleResponse(response)      }
    })    ?: throw Exception("Response is null")}

NowAttachmentService - delete(sysId: String)

Deletes the attachment with the specified sys_id.

Name Type Description
sysId String Sys_id of the attachment to delete.

Type

Description

Call<ByteArray>

Success: Nothing is returned.Failure: NowDataError returned.

``` fun deleteAttachment(sysId: String) { val call = attachmentService.delete(sysId) call.enqueue( { response -> handleResponse(response) }, { nowDataError -> handleError(nowDataError) } ) } ```

NowAttachmentService - upload(data: ByteArray, configuration: NowAttachmentUploadConfiguration)

Retrieves the metadata for all the attachments that meet the specified criteria and creates a paginator for iterating through pages of the returned metadata.

Name Type Description
data ByteArray Metadata to upload and associate with the attachment specified in the configuration object.
configuration NowAttachmentUploadConfiguration Upload configuration parameters.
Type Description
NowAttachmentMetadata Uploaded metadata.
Java
fun uploadAttachment(tableName: String, recordSysId: String, fileName: String) {   val bitmap = BitmapFactory.decodeResource(resources, R.drawable.test_image)   val data = bitmap.compress(ImageType.JPEG)   val contentType = "image/jpg"   val config = NowAttachmentUploadConfiguration(tableName, recordSysId, fileName, contentType)   val call = attachmentService.upload(data, config)    call.enqueue(     { response ->       val uploadedAttachmentMetadata: NowAttachmentMetadata? = response.body     },    { nowDataError -> handleError(nowDataError) }   )}
Search documentation
Search document titles and file paths on the australia branch