---
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


---

# Interact with the public REST API on a ServiceNow instance

# Interact with the public REST API on a ServiceNow instance {#ariaid-title1}

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

The Mobile SDK provides functionality that enables Android applications to call the public REST API on a ServiceNow instance.
Using the [NowAPIService](https://servicenow-prod.fluidtopics.net/Ruy5EdQ~h~QM1b7RygbeiA#NowAPIServiceAndroidInterface "The NowAPIService interface provides the ability to perform requests on a specified ServiceNow REST API.") API you can interact with any of the base ServiceNow public [REST APIs](https://servicenow-prod.fluidtopics.net/enjkhEuAw9paPBNoW_8S3Q "Use REST interfaces to access data on your instance."), or create custom REST APIs within the instance and call those from your Android application.

Before making a call to a ServiceNow REST API, you must call the[makeNowAPIService()](https://servicenow-prod.fluidtopics.net/7wukf9IvE6a_3xk6vwoh4g#NDataSDK-makeNowAPIService_S_O_O "Creates and initializes an instance of the NowAPIService service. This service allows you to access the public REST APIs exposed by your ServiceNow instance.") method to create an instance of the service. The service
instance is returned in the callback if successful otherwise, an error is thrown.  
The following shows how to initialize a NowAPIService object:

    /**
     * Helper class used to handle different Now service instances. It has an application scope or is Singleton
     */
    @Singleton
    class SdkManager @Inject constructor() {

        private var nowApiService: NowAPIService? = null

        /**
         * Create the NowAPIService once in the lifetime of the application inside the Application class or another manager class
         * that will be injected into other classes via dagger/hilt.
         * NowAPIService should be created after initializing the NowSDK
         */
        suspend fun getNowApiService(): NowAPIService? {
            if (nowApiService != null) return nowApiService

            return NowDataSDK.makeAPIService(URL("https://instance-name.service-now.com")).getOrThrow()
                .also { this.nowApiService = it }
        }

    }

Once the NowAPIService object is initialized, use the NowAPIService [data()](https://servicenow-prod.fluidtopics.net/Ruy5EdQ~h~QM1b7RygbeiA#NAPIServ-data_S_S_S_S "Calls the specified REST API on the specified ServiceNow instance.") method to specify the REST endpoint to call and all of its associated parameters:

     suspend fun makeNowApiCall() {
      val apiService = sdkManager.getNowApiService()

      val apiPath = "api/now/table/sn_customerservice_case"
      val endpoint = NowAPIService.Endpoint(HttpMethod.GET, apiPath, true)
      val fieldNames = "sys_id,number,short_description,number,priority,state," +
        "opened_at,account.name,account.number,contact.name,contact.email," +
        "contact_type,assignment_group.name,assigned_to.name"

      val queryParamsMap = mapOf("sysparm_fields" to fieldNames, "sysparm_limit" to "10")

      val queryParams = QueryParams.Builder().addAll(queryParamsMap).build()

      val response = runCatching {
        apiService?.data(endpoint = endpoint, queryParams = queryParams)?.execute()
      }

      if (response.isSuccess) {
        val resultString = response.getOrNull()?.body?.let { String(it) }
      } else {
        // Handle error
      }
    }


