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


---

# NowData framework - iOS

# NowData framework - iOS {#ariaid-title1}

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

The NowData framework contains methods that enable the instantiation of NowData services, such as NowGraphQLService, NowTableService, NowAPIService
(for custom APIs), and NowAttachmentService.

## NowData - makeApiService(instanceUrl: URL, path: String, completion: @escaping ((Result\<NowApiService, NowServiceError\>) -\> Void)) {#ariaid-title2}

Creates an instance of NowApiService, and once complete, calls the specified completion
handler.
{#NData-makeApiService_S_O__table_ff3_4pw_kqb__entry__3}

| Name | Type | Description |
|-|-|-|
| instanceUrl | URL | URL of the ServiceNow instance whose REST APIs are to be accessed by the service. |
| path | String | API path. For example, if the API call is `https://xxx.service-now.com/api/now/sg/incident`, the path is `/api/now/sg/incident`. |
| completion | @escaping ((Result​\<[NowApiService](https://servicenow-prod.fluidtopics.net/Gr1Q4dzJQJ291KR8~xiXQg#NowAPIServiceiOSAPI "The NowAPIService class provides functions that enable you to perform requests to a specified ServiceNow REST API."), Now​Service​Error\>) -\> Void) | Completion handler that is called with a `Result<NowApiService, NowServiceError>` containing either an initialized `NowApiService` instance or a `NowServiceError` indicating why the initialization failed. |
[Table 1. Parameters]

{#NData-makeApiService_S_O__table_ff3_4pw_kqb} {#NData-makeApiService_S_O__table_gf3_4pw_kqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 2. Returns]

{#NData-makeApiService_S_O__table_gf3_4pw_kqb}  
The following code example shows how to call this function.

    let path = "api/now/sg"
    let apiPublisher = apiService(for: path)

    func apiService(for path: String) -> AnyPublisher<NowAPIService, ConfigurationError> {
      guard let instanceURL else {
        return Fail(error: ConfigurationError.invalidInstanceURL)
        .eraseToAnyPublisher()
      }
      return Future { promise in
        NowData.makeApiService(instanceUrl: instanceURL, path: path) { (result) in
          promise(result.mapError { .sdkError($0) })
        }
      }
      .eraseToAnyPublisher()
    }

## NowData - makeAttachmentService(instanceUrl: URL, completion: @escaping
((Result\<NowAttachmentService, NowServiceError\>) -\> Void)) {#ariaid-title3}

Creates an instance of NowAttachmentService, and after completion, calls the specified completion handler.
{#NData-makeAttachmentService_S_O__table_nw3_hww_kqb__entry__3}

| Name | Type | Description |
|-|-|-|
| instanceUrl | URL | URL of the ServiceNow instance whose attachments are to be accessed by the service. |
| completion | @escaping ((Result​\<[NowAttachmentService](https://servicenow-prod.fluidtopics.net/MsIRssV78dlFdkKVybmzNg#NowAttachmentServiceiOSAPI "The NowAttachmentService class provides functions that enable you to upload and query attachments that are associated with records within a table on a ServiceNow instance."), Now​Service​Error\>) -\> Void) | Completion handler that is called with a `Result<NowAttachmentService, NowServiceError>` containing either an initialized `NowAttachmentService` instance or a `NowServiceError` indicating why the initialization failed. |
[Table 3. Parameters]

{#NData-makeAttachmentService_S_O__table_nw3_hww_kqb} {#NData-makeAttachmentService_S_O__table_ow3_hww_kqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 4. Returns]

{#NData-makeAttachmentService_S_O__table_ow3_hww_kqb}  
The following code example shows how to call this function.

    ....
    guard 
      let jwtUrl = URL(string: "http://13.57.38.237:8080"),
      let instanceUrl = URL(string: "https://mobilecoresdk.service-now.com") else {
        return
      }

    // AuthorizationProvider -- struct conforming to NowSDKAuthorizationProviding protocol
    let authorizationProvider = AuthorizationProvider(userEmail: "sdk@servicenow.com", jwtProviderUrl: jwtUrl, clientId: "deb8756b452d201039231ca568f26511")
            
    // PermissionProvider -- class conforming to DevicePermissionDelegate protocol
    let permissionProvider = PermissionProvider()
    let config = NowSDKConfiguration(authorizationProvider: authorizationProvider, permissionDelegate: permissionProvider, logLevel: .debug)
    	
    do {
      try NowSDK.configure(with: config)
      initializeAttachmentService (with: instanceURL)
    } catch {
      // Return ConfigurationError.sdkError(error)
    }
    .....

    func initializeAttachmentService(instanceUrl: instanceURL) { result in
      switch result {
        case .success(let service)
          self?.attachmentService = service
        case .failure(let error)
          debug.print("Creating Attachment service failed with error: \(error.localizedDescription)")
          self?.attachmentService = nil
      }
    }

## NowData - makeGraphQLService(instanceUrl: URL, completion: @escaping
((Result\<NowGraphQLService, NowServiceError\>) -\> Void)) {#ariaid-title4}

Creates an instance of NowGraphQLService, and once complete, calls the specified
completion handler.
{#NData-makeGraphQLService_S_O__table_fb2_mcw_kqb__entry__3}

| Name | Type | Description |
|-|-|-|
| instanceUrl | URL | URL of the ServiceNow instance providing GraphQL services. |
| completion | @escaping ((Result​\<[NowGraphQLService](https://servicenow-prod.fluidtopics.net/AEmOcE5BY9GRAKMwbs6uoA#NowGraphQLServiceiOSAPI "The NowGraphQLService class provides functions that enable you to make requests using GraphQL queries against data on your ServiceNow instance through its GraphQL REST API."), Now​Service​Error\>) -\> Void) | Completion handler that is called with a `Result<NowGraphQLService, NowServiceError>` containing either an initialized `NowGraphQLService` instance or a `NowServiceError` indicating why the initialization failed. |
[Table 5. Parameters]

{#NData-makeGraphQLService_S_O__table_fb2_mcw_kqb} {#NData-makeGraphQLService_S_O__table_gb2_mcw_kqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 6. Returns]

{#NData-makeGraphQLService_S_O__table_gb2_mcw_kqb}  
<br />

    func initializeGraphQLService(instanceUrl: URL) {
      makeGraphQLService(instanceUrl: instanceUrl) { [weak self] result in
        switch result {
        case .success(let service):
          self?.graphQLService = service
        case .failure(let error):
          debugPrint("Creating GraphQL service failed with error: \(error.localizedDescription)")
          self?.graphQLService = nil
        }
      }
    }

## NowData - makeTableService(instanceUrl: URL, completion: @escaping
((Result\<NowTableService, NowServiceError\>) -\> Void)) {#ariaid-title5}

Creates an instance of NowTableService, and after it completes, calls the specified completion handler.
{#NData-makeTableService_S_O__table_rkh_bmw_kqb__entry__3}

| Name | Type | Description |
|-|-|-|
| instanceUrl | URL | URL of the ServiceNow instance whose tables are to be accessed by the service. |
| completion | @escaping ((Result​\<[NowTableService](https://servicenow-prod.fluidtopics.net/Mg9nOO4u3WPRvIqz4t9SUw#NowTableServiceiOSAPI "The NowTableService class provides functions that enable you to perform create, read, update, and delete operations on records of existing ServiceNow tables."), Now​Service​Error\>) -\> Void) | Completion handler that is called with a `Result<NowTableService, NowServiceError>` containing either an initialized `NowTableService` instance or a `NowServiceError` indicating why the initialization failed. |
[Table 7. Parameters]

{#NData-makeTableService_S_O__table_rkh_bmw_kqb} {#NData-makeTableService_S_O__table_skh_bmw_kqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 8. Returns]

{#NData-makeTableService_S_O__table_skh_bmw_kqb}  
The following code example shows how to call this function.

    func initializeTableService(for instanceUrl: URL) {
      makeTableService(instanceUrl: instanceUrl) { [weak self] result in
        guard let self = self else { return }
                
        switch result {
          case .success(let tableService):
            self.tableService = tableService
            // Create a Paginator that will iterate over pages of customer support cases. The Paginator's response type will be
            // inferred from the Paginator's type definition (e.g. `Paginator<[CustomerServiceCase]>`).
            self.paginator = tableService.paginator(from: Self.tableName, configuration: self.fetchConfiguration)
            // Subscribe to the Paginator's publisher so we will be able to receive paged results.
            self.subscribeToPaginatorPublisher()
            // As we are now ready to start fetching data, inform the view controller.
            self.onReady(self)
          case .failure(let error):
            debugPrint("Creating table service failed with error: \(error.localizedDescription)")
            self.tableService = nil
            self.paginator = nil
        }
      }
    }


