---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowAPIService interface - Android

# NowAPIService interface - Android {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The NowAPIService interface provides the ability to perform requests
on a specified ServiceNow REST API.  
Note:  
Guest users only work for the NowAPIService interface if the REST API being accessed is configured for guest users.
{#NowAPIServiceAndroidInterface__table_vx2_klw_5pb__entry__3}

| Name | Type | Description |
|-|-|-|
| configuration | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/Csuh2Bp1F37gr9cX8Z4xFg "The NowServiceConfiguration class enables you to configure the ServiceNow instance URL and package name for a feature service.") | Service configuration to associate with the protocol. |
[Table 1. Properties]

{#NowAPIServiceAndroidInterface__table_vx2_klw_5pb}

## NowAPIService - data(endpoint: NowAPIService.Endpoint, queryParams: QueryParams, headers:
Headers, body: String) {#ariaid-title2}

Calls the specified REST API on the specified ServiceNow
instance.
{#NAPIServ-data_S_S_S_S__table_u3p_dkt_4pb__entry__3}

| Name | Type | Description |
|-|-|-|
| endpoint | NowAPIService.Endpoint | REST endpoint to call. |
| queryParams | QueryParams | Optional. Query parameter object that contains the query parameters to pass in the REST call. Default: null |
| headers | Headers | Optional. Headers object that contains the headers to pass in the REST call. Default: null |
| body | String | Optional. Object that contains the request body and content type to pass into the REST call. Default: null |
[Table 2. Parameters]

{#NAPIServ-data_S_S_S_S__table_u3p_dkt_4pb} {#NAPIServ-data_S_S_S_S__table_v3p_dkt_4pb__entry__2}

| Type | Description |
|-|-|
| [Call](https://servicenow-prod.fluidtopics.net/QqQzdE2jNcRyZ9uTF8c1wg#CallAndroidInterface "The Call interface represents a request that is prepared for processing.")\<[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/)\> | Return results from the called REST endpoint. |
[Table 3. Returns]

{#NAPIServ-data_S_S_S_S__table_v3p_dkt_4pb}  
<br />

    suspend fun loadCases(): List<CaseItem> = withContext(Dispatchers.IO) {
      val apiService = nowServiceManager.getNowAPIService()

      val result = runCatching {
        val response = apiService.data(NowAPIService.Endpoint(
          relativePath = CASES_API,
          requestMethod = HttpMethod.GET,
          requireAuth = true)
        ).execute()

        val byteArray = response.body ?: throw Exception("Null Result")
        val buffer = Buffer()
        val reader = JsonReader.of(buffer.write(byteArray))
        val listType = Types.newParameterizedType(
          List::class.java,
          CaseItem::class.java
        )

        val resultType = Types.newParameterizedType(
          ResultResponse::class.java,
          listType
        )
        val adapter = moshi.adapter<ResultResponse<List<CaseItem>>>(resultType)
        adapter.fromJson(reader)
      }

      if (result.isSuccess) {
          result.getOrNull()?.result ?: throw Exception("Cases not in response")
      } else {
          throw result.exceptionOrNull() ?: Exception("Error Cases")
      }
    }


