### C# Integration Source Code Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/DCManager/concept/DCManagerAPIGlobal
A consolidated example of C# source code for integrating with ServiceNow web services, including setup, authentication, and a sample API call.
```csharp
// using System;
// using System.Net;
// using ServiceNowWebIncident;
// public class CSharpIntegration
// {
// public static void Main(string[] args)
// {
// ServiceNowWebIncident.incident service = new ServiceNowWebIncident.incident();
// service.Credentials = new NetworkCredential("your_username", "your_password");
// string query = "active=true";
// string[] fields = { "number", "short_description", "state" };
// try
// {
// // var incidents = service.getRecords(null, query, fields);
// // if (incidents != null && incidents.getRecordsResponse != null)
// // {
// // foreach (var incident in incidents.getRecordsResponse)
// // {
// // Console.WriteLine($"Incident: {incident.number} - {incident.short_description} (State: {incident.state})");
// // }
// // }
// }
// catch (Exception ex)
// {
// Console.WriteLine($"An error occurred: {ex.Message}");
// }
// }
// }
```
--------------------------------
### Python Client Examples for ServiceNow SOAP
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CriteriaEvaluator/concept/c_CriteriaEvaluatorAPI
Demonstrates how to interact with ServiceNow SOAP web services using Python. Examples cover basic client setup and request execution.
```python
# Example Python script for consuming ServiceNow SOAP web services
# Requires a library like Zeep or Suds
# ... implementation details ...
```
--------------------------------
### Web services C Sharp .NET End to End Tutorial
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/RESTMessageV2/reference/r_RecordlessRESTMessageV2Example
A guide for integrating ServiceNow using C# and .NET, detailing the process from configuration to troubleshooting. It covers using different reference types and provides source code examples.
```C#
// Example: C# integration source code snippet
/*
using System;
using System.Net;
using System.Text;
using System.IO;
// ... code to construct and send HTTP request to ServiceNow ...
string url = "https://yourinstance.service-now.com/api/now/table/incident";
string username = "your_username";
string password = "your_password";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password)));
string jsonPayload = "{\"short_description\": \"C# .NET End to End Test\", \"description\": \"This is a test incident created via C#.\"}";
byte[] byteArray = Encoding.UTF8.GetBytes(jsonPayload);
request.ContentLength = byteArray.Length;
using (Stream dataStream = request.GetRequestStream()) {
dataStream.Write(byteArray, 0, byteArray.Length);
}
WebResponse response = null;
try {
response = (HttpWebResponse)request.GetResponse();
using (Stream stream = response.GetResponseStream()) {
using (StreamReader reader = new StreamReader(stream)) {
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
}
}
} catch (WebException ex) {
Console.WriteLine("Error: " + ex.Message);
} finally {
if (response != null) ((IDisposable)response).Dispose();
}
*/
```
--------------------------------
### Getting Started with ODBC
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideDBFunctionBuilderScoped/concept/GlideDBFunctionBuilderScopedAPI
Initial steps and prerequisites for using the ODBC driver, including user account setup and ACL rules.
```APIDOC
## Getting Started with ODBC
### Description
Covers the fundamental setup required before utilizing the ODBC driver, including user account creation and defining access control rules.
### Setup Procedures
- Create an ODBC user account and assign the odbc role
- Define an ACL rule for the odbc role
```
--------------------------------
### SOAP Web Service Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MobileSDKAndroid/NowSDKConfiguration/concept/NowSDKConfigurationAndroidAPI
Demonstrates how to interact with ServiceNow SOAP web services using different client languages. Includes examples for data retrieval, modification, and advanced operations.
```java
/**
* Example of a Java Apache Axis2 client for ServiceNow SOAP insert operation.
* Assumes Axis2 environment and necessary stubs are generated.
*/
// Placeholder for actual Java code
// Example:
// com.service_now.ExampleStub stub = new com.service_now.ExampleStub();
// com.service_now.InsertRequest req = new com.service_now.InsertRequest();
// req.setTableName("incident");
// // ... set other fields ...
// com.service_now.InsertResponse res = stub.insert(req);
// System.out.println("Record inserted: " + res.getResult());
```
```java
/**
* Example of a Java Apache Axis2 client for ServiceNow SOAP update operation.
* Assumes Axis2 environment and necessary stubs are generated.
*/
// Placeholder for actual Java code
// Example:
// com.service_now.ExampleStub stub = new com.service_now.ExampleStub();
// com.service_now.UpdateRequest req = new com.service_now.UpdateRequest();
// req.setTableName("incident");
// req.setSysId("your_sys_id");
// // ... set fields to update ...
// com.service_now.UpdateResponse res = stub.update(req);
// System.out.println("Record updated: " + res.getResult());
```
```java
/**
* Example of a Java Apache Axis2 client for advanced ServiceNow SOAP operations.
* This is a conceptual placeholder for more complex interactions.
*/
// Placeholder for actual Java code
// Example: Using aggregate API or other advanced features.
```
```csharp
/**
* Example of a C# .NET client using a service reference to call a ServiceNow SOAP web service.
*/
// Placeholder for actual C# code
// Example:
// using (var client = new ServiceNow.ServiceReference.YourServiceNowClient())
// {
// // Configure authentication if needed
// // client.Credentials = new NetworkCredential("user", "password");
//
// // Example: Calling an insert operation
// var request = new ServiceNow.ServiceReference.InsertRequest();
// request.tableName = "incident";
// // ... set other fields ...
// var response = client.insert(request);
// Console.WriteLine("Record inserted: " + response.result);
// }
```
```csharp
/**
* Example of a C# .NET client using a web reference to call a ServiceNow SOAP web service.
*/
// Placeholder for actual C# code
// Example:
// using (var client = new ServiceNow.WebReference.YourServiceNowClient())
// {
// // Configure authentication if needed
// // client.Credentials = new NetworkCredential("user", "password");
//
// // Example: Calling an update operation
// var request = new ServiceNow.WebReference.UpdateRequest();
// request.tableName = "incident";
// request.sysId = "your_sys_id";
// // ... set fields to update ...
// var response = client.update(request);
// Console.WriteLine("Record updated: " + response.result);
// }
```
```csharp
// C# integration source code examples would go here, potentially including:
// - Data contracts for request/response objects.
// - Helper methods for constructing requests.
// - Error handling logic.
// - Authentication implementations.
```
```perl
# Placeholder for Perl web services client examples.
# Perl clients often use modules like LWP::UserAgent and SOAP::Lite.
# Example structure:
# use SOAP::Lite;
# my $soap = SOAP::Lite->uri('http://www.service-now.com/your_table')
# ->proxy('http://your_instance.service-now.com/your_table.do');
# my $result = $soap->insert(...);
```
```python
# Placeholder for Python web services client examples.
# Python clients often use libraries like 'requests' for REST or 'zeep' for SOAP.
# Example structure for SOAP:
# from zeep import Client
# client = Client('http://your_instance.service-now.com/your_table.do?WSDL')
# result = client.service.insert(...)
```
--------------------------------
### OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MIDServerCluster/concept/c_MIDServerClusterAPI
Steps to create an OAuth provider and profile for the tutorial.
```APIDOC
## OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
### Description
This subsection guides the user through creating the necessary OAuth provider and profile configurations within ServiceNow for the tutorial.
### Method
N/A (Tutorial Step)
### Endpoint
N/A (Tutorial Step)
```
--------------------------------
### ServiceNow StopWatch getTime() Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/StopWatchNX/concept/StopWatchAPINX
Demonstrates how to get the elapsed time in milliseconds since the StopWatch was started or last restarted. This is useful for precise time measurements.
```javascript
var timer = new nowapi.StopWatch();
console.log(timer.started); //logs the StopWatch start date and time to the console
var millis = timer.getTime();
```
--------------------------------
### SOAP Data Retrieval API - get
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/DocumentListEntryService/concept/DocumentListEntryServiceBothAPI
Example of using the 'get' function from the SOAP Data Retrieval API to retrieve a single record by its sys_id.
```javascript
// SOAP request to get a specific incident record
YOUR_INCIDENT_SYS_ID
```
--------------------------------
### C# .NET Client Examples for SOAP Web Services
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/Fetch/concept/FetchAPI
Demonstrates how to build C# .NET clients to consume ServiceNow SOAP web services. Covers using service references, web references, and provides sample integration source code.
```csharp
using System;
using YourServiceNamespace.YourService;
public class ServiceNowClient
{
public void CallWebService(string username, string password)
{
var service = new YourServiceSoapClient(); // Using a service reference
// Configure credentials
// Call methods on the service object
// Process the response
}
}
```
```csharp
using System;
using System.Net;
public class ServiceNowWebReferenceClient
{
public void CallWebService(string username, string password)
{
var service = new YourWebReferenceNamespace.YourService(); // Using a web reference
service.Credentials = new NetworkCredential(username, password);
// Call methods on the service object
// Process the response
}
}
```
--------------------------------
### SOAP Web Service Examples (Java, C#, PHP)
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CabrilloNowApp-client/concept/cabrillo-nowapp-namespace
Examples demonstrating how to fetch XML data using basic authentication for SOAP web services. This includes strategies like using filters, local data stores, and direct code implementation.
```Java
// Java code example for fetching XML data using basic authentication
// (Implementation details would follow)
```
```C#
// C# code example for fetching XML data using basic authentication
// (Implementation details would follow)
```
```PHP
// PHP code example for fetching XML data using basic authentication
// (Implementation details would follow)
```
--------------------------------
### Web Services C Sharp .NET End-to-End Tutorial
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CIIdentification/concept/c_CIIdentificationAPI
This tutorial guides users through setting up and consuming ServiceNow web services using C# and .NET. It covers project configuration in Visual Studio and practical integration steps.
```csharp
// This section refers to a tutorial, not a direct code snippet.
// The code examples would be found within the tutorial itself, likely involving:
// 1. Creating a new C# project in Visual Studio.
// 2. Adding a Service Reference or Web Reference to the ServiceNow WSDL.
// 3. Instantiating the generated client proxy class.
// 4. Configuring authentication (e.g., basic authentication).
// 5. Calling methods on the client proxy to interact with ServiceNow APIs (e.g., get, insert, update).
// 6. Handling the response objects.
// Example structure:
/*
using YourServiceReference;
public class ServiceNowIntegration
{
public void FetchIncidents()
{
using (var client = new YourServiceReference.ServiceNowSoapClient())
{
// Configure authentication
client.ClientCredentials.UserName.UserName = "your_username";
client.ClientCredentials.UserName.Password = "your_password";
// Prepare query parameters
var query = "active=true^priority=1";
var fields = "number,short_description,state";
var limit = 10;
// Call the getRecords method
var response = client.getRecords("incident", query, fields, limit);
// Process the response
foreach (var incident in response.result)
{
Console.WriteLine($"Number: {incident.number}, State: {incident.state}");
}
}
}
}
*/
```
--------------------------------
### Python Web Services Client Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/SNMPResponse/concept/c_SNMPResponseAPI
This snippet provides an example of how to interact with ServiceNow's SOAP web services using Python. It typically involves using libraries like `zeep` or `requests` to construct and send SOAP requests, handle authentication, and parse responses. Ensure the `zeep` library is installed (`pip install zeep`).
```python
from zeep import Client
from zeep.transports import Transport
from requests.auth import HTTPBasicAuth
# Replace with your ServiceNow instance URL and WSDL path
wsdl_url = "https://yourinstance.service-now.com/your_service.do?WSDL"
username = "your_username"
password = "your_password"
try:
auth = HTTPBasicAuth(username, password)
transport = Transport(http_client=auth)
client = Client(wsdl_url, transport=transport)
# Example: Calling a getRecords method (adjust method name and parameters)
# result = client.service.getRecords(tableName='incident', sysparm_query='priority=1')
# Example: Calling an insert method
# record_data = {
# 'short_description': 'Python Insert Example',
# 'description': 'This is a test record.'
# }
# result = client.service.insert(tableName='incident', record=record_data)
# print(result)
except Exception as e:
print(f"An error occurred: {e}")
```
--------------------------------
### Web Service Client Example (C# .NET)
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MobileSDKiOS/NowChatServiceDelegate/concept/NowChatServiceDelegateiOSProtocol
A comprehensive tutorial for integrating with ServiceNow using C# and .NET, covering configuration, calling web services, and troubleshooting.
```C#
// Configure C# with .NET
// Ensure you have the necessary .NET framework or Core version installed.
// You might need to install NuGet packages like 'System.ServiceModel.Primitives' or similar depending on your project type.
// Call a web service in Visual Studio .NET
// 1. Add Service Reference: Right-click project -> Add -> Service Reference -> Advanced -> Add Web Reference.
// Use the WSDL URL, e.g., https://.service-now.com/incident.do?WSDL
// 2. Use a service reference in a C# integration:
// using ServiceNowIntegration.ServiceNowIncidentService;
//
// public class ServiceNowHelper
// {
// public string CreateIncident(string shortDescription, string description)
// {
// IncidentService incidentService = new IncidentService();
// incidentService.Url = "https://.service-now.com/incident.do";
// incidentService.Credentials = new System.Net.NetworkCredential("username", "password");
//
// Incident incident = new Incident()
// {
// short_description = shortDescription,
// description = description
// };
//
// InsertResponse response = incidentService.insert(incident);
// return response.sys_id;
// }
// }
// 3. Use a web reference in a C# integration:
// (Similar process, but involves adding a Web Reference instead of a Service Reference.
// The generated client class names might differ.)
// C# integration source code example (within a class):
// public class CSharpIntegration
// {
// public void ExampleUsage()
// {
// ServiceNowHelper helper = new ServiceNowHelper();
// string sysId = helper.CreateIncident("Test Incident from C#", "Details about the incident.");
// Console.WriteLine($"Incident created with sys_id: {sysId}");
// }
// }
// Troubleshoot a null response in a C# integration:
// - Check credentials and endpoint URL.
// - Ensure the web service method is correctly called and parameters match.
// - Inspect the SOAP request and response using tools like Fiddler or network tracing.
// - Verify the ServiceNow user has the necessary roles and permissions.
// - Check ServiceNow logs for errors related to the inbound web service call.
```
--------------------------------
### Voice Interaction Response Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/VoiceTranscriptObjectScoped/concept/VoiceTranscriptObjectScopedAPI
This section provides examples of the expected JSON responses when starting a voice interaction. The 'Success' example shows a typical response with an interaction ID and a status of 'SUCCESS'. The 'Error' example illustrates a potential failure response, including an error message detailing the exception that occurred during the interaction startup, with a status of 'FAILED'. These examples are crucial for error handling and confirming the successful initiation of voice sessions.
```json
// Success
{"interactionId":"ea01113cb7f71110b6e8bc15ae11a950","status":"SUCCESS"}
// Error
{"error":"Exception occurred while starting the interaction: ","status":"FAILED"}
```
--------------------------------
### Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/OrderUtil/concept/OrderUtilScopedAPI
Code examples and tutorials for integrating with ServiceNow web services using various client technologies.
```APIDOC
## Web Services Client Examples
### Description
Provides client-side code examples and tutorials for integrating with ServiceNow web services using different programming languages and technologies.
### Supported Clients
- Java Apache Axis2 web services client examples (insert, update, advanced)
- Microsoft .NET web services client examples
- Perl web services client examples
- Python web services client examples
- C# .NET web services client examples (end-to-end tutorial, configuration, service/web reference usage, source code, troubleshooting)
- ASP.NET with C# redirect with cookies example
- ASP Script for unencrypted single sign-on example
```
--------------------------------
### Java Apache Axis2 SOAP Client - Insert Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/SPModal/concept/SPModal-API
Example of using Java Apache Axis2 to call a ServiceNow SOAP web service for inserting records. This demonstrates the client-side setup for interacting with ServiceNow.
```java
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;
// Assuming MyServiceStub is generated from WSDL
MyServiceStub stub = new MyServiceStub("http://your-instance.service-now.com/my_soap_service.do?WSDL");
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
// Set authentication if needed
// options.setManageSession(true);
// Create request object
MyServiceStub.InsertRecordRequest request = new MyServiceStub.InsertRecordRequest();
// Populate request object fields
// Execute the operation
MyServiceStub.InsertRecordResponse response = stub.insertRecord(request);
// Process response
```
--------------------------------
### OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/JSON/concept/c_JSONAPI
Guides on creating OAuth provider and profile configurations.
```APIDOC
## N/A (OAuth Configuration Tutorial)
### Description
Walkthrough for creating the necessary OAuth provider and profile configurations for authentication.
### Method
N/A (OAuth Configuration Tutorial)
### Endpoint
N/A (OAuth Configuration Tutorial)
```
--------------------------------
### Mobile SDK Developer Guide - Android
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CIIdentification/concept/c_CIIdentificationAPI
This section provides developer guides for integrating and utilizing the ServiceNow Mobile SDK for Android applications. It covers architecture, setup, initialization, and interaction with ServiceNow instance features.
```APIDOC
## Mobile SDK Developer Guide - Android
This guide covers the integration and usage of the ServiceNow Mobile SDK for Android.
### Sections
- **NowSDK architecture**
- **Get started with Mobile SDK - Android**
- Download and install the Mobile SDK library
- Install and configure the Mobile SDK scoped application
- Configure your project
- Configure certificate and create an OAuth Entity
- Configure guest user access
- **Initialize the NowSDK in your application**
- **Implement Virtual and Live Agent chat**
- Pass NowChatConfiguration to modify the behavior of NowChat
- **Interact with table data in a ServiceNow instance**
- Configure return results data
- Configure field write options
- Paginate return results record sets
- Configure tables to work with guests
- **Interact with the public REST API on a ServiceNow instance**
- **Retrieve attachments and attachment metadata**
- **Display web pages hosted on your ServiceNow instance**
- **Configure push notifications**
```
--------------------------------
### C# Integration Source Code Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MobileSDKAndroid/FetchConfiguration/concept/FetchConfigAndroidAPI
Presents a complete C# source code example for integrating with ServiceNow web services. This includes setting up the client, handling authentication, and making sample API calls.
```csharp
// This is a comprehensive example combining previous C# snippets.
// Assumes a service reference named 'ServiceNowService' has been added.
using System;
using System.ServiceModel;
using ServiceNowService;
public class ServiceNowIntegration
{
public static void Main(string[] args)
{
try
{
using (var client = new ServiceNowClient())
{
client.Endpoint.Address = new EndpointAddress("https://your_instance.service-now.com/incident.do?SOAP");
client.ClientCredentials.UserName.UserName = "your_username";
client.ClientCredentials.UserName.Password = "your_password";
// Example: Insert a new incident
var newIncident = new Incident
{
Short_description = "C# Integration Test",
Description = "Testing insert operation."
};
var insertResponse = client.insert(newIncident);
Console.WriteLine($"Incident inserted with sys_id: {insertResponse.result.sys_id}");
// Example: Get an incident
var getRequest = new GetRequest
{
Table = "incident",
SysId = insertResponse.result.sys_id
};
var getResponse = client.get(getRequest);
if (getResponse.result != null)
{
Console.WriteLine($"Retrieved incident: {getResponse.result.number} - {getResponse.result.short_description}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}
```
--------------------------------
### SOAP Web Service Examples for Data Retrieval and Modification
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/ScriptableUriMatcherBoth/concept/ScriptableUriMatcherBothAPI
Examples demonstrating the use of ServiceNow's SOAP Data Retrieval and Data Modification APIs for common operations like getting records, inserting, updating, and deleting data. These examples assume a configured SOAP endpoint and appropriate authentication.
```javascript
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
while (gr.next()) {
gs.info(gr.number + ': ' + gr.short_description);
}
```
```javascript
var newIncident = new GlideRecord('incident');
newIncident.initialize();
newIncident.short_description = 'SOAP Insert Example';
newIncident.description = 'Incident created via SOAP insert';
var sysID = newIncident.insert();
gs.info('New incident created with sys_id: ' + sysID);
```
```javascript
var gr = new GlideRecord('incident');
gr.get('YOUR_INCIDENT_SYS_ID');
gr.short_description = 'SOAP Update Example';
gr.update();
gs.info('Incident updated.');
```
```javascript
var gr = new GlideRecord('incident');
gr.get('YOUR_INCIDENT_SYS_ID');
gr.deleteRecord();
gs.info('Incident deleted.');
```
--------------------------------
### C# .NET Web Service Integration Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/openFrameAPI/concept/c_openFrameAPI
Details the process of integrating with ServiceNow using C# and .NET, covering configuration, calling web services via service or web references, and providing sample source code.
```csharp
// Example of using a Service Reference in C#
// (Assumes a ServiceNow proxy class named 'ServiceNowAPIProxy' has been generated)
// using ServiceNowAPIProxy;
// public class ServiceNowIntegration
// {
// public void CreateIncident(string shortDescription, string description)
// {
// using (var client = new ServiceNowAPIProxy.ServiceNowAPIProxyClient())
// {
// // Configure authentication (e.g., Basic Auth header)
// // client.ClientCredentials.UserName.UserName = "your_username";
// // client.ClientCredentials.UserName.Password = "your_password";
// var incident = new ServiceNowAPIProxy.incident()
// {
// short_description = shortDescription,
// description = description
// };
// // Call the insert method
// // string sysId = client.insert(incident);
// // Console.WriteLine("Inserted Incident Sys ID: " + sysId);
// }
// }
// }
// Example of using a Web Reference in C# (older approach)
// (Assumes a ServiceNow proxy class named 'YourWebReferenceName')
// using YourWebReferenceName;
// public class ServiceNowIntegrationWebRef
// {
// public void UpdateIncident(string sysId, string state)
// {
// using (var service = new YourWebReferenceName.ServiceNowAPI())
// {
// // Configure authentication
// // service.Credentials = new System.Net.NetworkCredential("your_username", "your_password");
// // Call the update method
// // var result = service.update(sysId, new YourWebReferenceName.incident() { state = state });
// // Console.WriteLine("Update Result: " + result);
// }
// }
// }
```
--------------------------------
### C# .NET Web Services Client End-to-End Tutorial
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MLSolutionUtil/concept/MLSolutionUtilAPI
A tutorial for integrating with ServiceNow using C# and .NET. Covers configuring C# with .NET, calling web services in Visual Studio, and using service or web references. Includes source code examples.
```C#
// Configure C sharp with .NET
// Call a web service in visual studio .NET
// Use a service reference in a C Sharp integration
// Use a web reference in a C Sharp integration
// C Sharp integration source code
```
--------------------------------
### C# Integration Source Code Example
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/VoiceTranscriptObjectScoped/concept/VoiceTranscriptObjectScopedAPI
This C# code provides a concrete example of integrating with ServiceNow, likely demonstrating a specific task like creating or updating a record. It serves as a practical guide for C# developers.
```C#
using System;
using System
```
--------------------------------
### Developer Guides
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideNavigationClientNX/concept/GlideNavigationClientAPINX
Resources and guides for developers working with ServiceNow APIs in Zurich.
```APIDOC
## Developer Guides
### Description
This section provides links to developer guides for working with various ServiceNow APIs in the Zurich release. These guides offer insights into implementation, best practices, and examples.
### Method
N/A (This is a general reference)
### Endpoint
N/A (This is a general reference)
### Parameters
N/A (This is a general reference)
### Request Example
N/A (This is a general reference)
### Response
N/A (This is a general reference)
#### Response Example
N/A (This is a general reference)
```
--------------------------------
### Perl Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideDBFunctionBuilderScoped/concept/GlideDBFunctionBuilderScopedAPI
Code snippets demonstrating how to create a web services client using Perl. These examples provide a starting point for integrating Perl applications with ServiceNow's web services.
```Perl
# Perl web services client example
# Requires LWP::UserAgent or similar modules
```
--------------------------------
### Java Apache Axis2 Client Example - Insert
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CabrilloModal-client/concept/cabrillo-modal-namespace
Example of using a Java Apache Axis2 client to insert records into ServiceNow via SOAP web services. Requires proper Axis2 setup and WSDL import.
```java
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import java.util.Map;
import java.util.HashMap;
// ... (Service Stub and Operation Stub classes generated from WSDL)
public class ServiceNowInsertClient {
public static void main(String[] args) {
try {
String endpoint = "http://yourinstance.service-now.com/your_table.do?SOAP";
String username = "your_username";
String password = "your_password";
// Assuming you have generated a stub for your table's web service
YourTableStub stub = new YourTableStub(endpoint);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
options.setManageSession(true);
options.setProperty(HTTPConstants.CHUNKED, false);
options.setUserName(username);
options.setPassword(password);
// Construct the data to insert
Map recordData = new HashMap<>();
recordData.put("short_description", "Java Insert Example");
recordData.put("priority", "2");
// Assuming 'insert' is the method in your generated stub
// The parameters will depend on the WSDL structure
// stub.insert(recordData);
System.out.println("Record insertion attempt initiated.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
```
--------------------------------
### OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/Fetch/concept/FetchAPI
Creating an OAuth provider and profile for use with Google.
```APIDOC
## OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
### Description
This step outlines the creation of a specific OAuth provider and profile within ServiceNow, tailored for the Google integration.
### Method
N/A (Tutorial Step)
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```
--------------------------------
### Python Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/ProducerV2/concept/ProducerV2ScopedAPI
Code examples illustrating how to build web services clients using Python for ServiceNow integrations.
```python
# Example for Python web services client
# Placeholder for actual Python code
print("Python web services client example")
```
--------------------------------
### SOAP Web Service - Data Retrieval API Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CIIdentifierResult/concept/c_CIIdentifierResultAPI
Examples of using the Data Retrieval API for SOAP web services. This includes functions like getKeys, getRecords, get, and aggregate to fetch data from ServiceNow.
```javascript
function getKeysExample() {
// Example of using getKeys()
}
function getRecordsExample() {
// Example of using getRecords()
}
function getExample() {
// Example of using get()
}
function aggregateExample() {
// Example of using aggregate()
}
```
--------------------------------
### C# Integration with .NET Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/TableUtils/concept/c_TableUtilsAPI
Details on configuring C# with .NET, calling web services in Visual Studio, and using service or web references for integration.
```csharp
// Example: Configure C sharp with .NET
// In Visual Studio, right-click on project -> Add Service Reference or Add Web Reference
// Example: Use a service reference in a C Sharp integration
// using YourServiceReference;
// YourServiceClient client = new YourServiceClient();
// var response = client.Insert(request);
// Example: Use a web reference in a C Sharp integration
// using YourWebReference;
// YourWebService service = new YourWebService();
// var response = service.Insert(request);
// Example: C Sharp integration source code
public void CreateIncident(string shortDescription) {
// ... client or service initialization ...
// var incident = new Incident { ShortDescription = shortDescription };
// client.Insert(incident);
}
```
--------------------------------
### Using GlideDBFunctionBuilder.position()
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideDBFunctionBuilderScoped/concept/GlideDBFunctionBuilderScopedAPI
Example demonstrating how to use the position() method to find the starting position of a substring within a table column.
```APIDOC
## POST /api/now/table/{tableName}
### Description
This example shows how to use `GlideDBFunctionBuilder` to construct a database function that finds the position of a substring within a specified column. The resulting function can be used with `GlideRecord` to query records based on this function's output.
### Method
```
POST
```
### Endpoint
```
/api/now/table/{tableName}
```
### Parameters
#### Request Body
- **short_description** (string) - Required - The text to search for within the column.
- **field** (string) - Required - The name of the table column to search within.
- **tableName** (string) - Required - The name of the table to query.
### Request Example
```json
{
"short_description": "my",
"field": "short_description",
"tableName": "incident"
}
```
### Response
#### Success Response (200)
- **result** (array) - An array of records matching the query.
- **short_description** (string) - The short description of the incident.
- **getValue(dbFunction)** (integer) - The position of the search term in the short description.
#### Response Example
```json
{
"result": [
{
"short_description": "My incident description",
"getValue(dbFunction)": 1
}
]
}
```
### Code Example
```javascript
var functionBuilder = new GlideDBFunctionBuilder();
var dbFunction = functionBuilder.position();
dbFunction = functionBuilder.constant('my'); // search_term: Text to search for in the specified table column.
dbFunction = functionBuilder.field('short_description'); // column: Name of the table column to search.
dbFunction = functionBuilder.build();
gs.log(dbFunction);
var gr_incident = new GlideRecord('incident'); // Table containing the column to search
gr_incident.addFunction(dbFunction);
gr_incident.addQuery("short_description", "CONTAINS", "my");
gr_incident.setLimit(20);
gr_incident.query();
while(gr_incident.next()) {
gs.info(gr_incident.short_description + "\n position('my', short_description): " + gr_incident.getValue(dbFunction));
}
```
```
--------------------------------
### ODBC Driver for Data Sources
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideDigestScoped/concept/c_GlideDigestScopedAPI
Guides on creating data sources from other applications using the ODBC driver, including installation and configuration.
```APIDOC
## Create Data Sources from Other Apps Using ODBC Driver
### Description
This section covers the process of creating external data sources by utilizing the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Getting Started with ODBC
### Description
Initial steps and prerequisites for working with the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Create an ODBC User Account and Assign the odbc Role
### Description
Instructions for creating a user account and assigning the necessary 'odbc' role.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Define an ACL Rule for the odbc Role
### Description
Guidance on defining Access Control List (ACL) rules for the 'odbc' role.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Installing the ODBC Driver
### Description
Detailed steps for installing the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## ODBC Driver Installation Requirements and Supported Software
### Description
Information on the system requirements and compatible software for ODBC driver installation.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Download and Install the ODBC Driver
### Description
Step-by-step instructions for downloading and installing the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Upgrade the ODBC Driver
### Description
Guidance on how to upgrade an existing ODBC driver installation.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Install an ODBC Driver Patch
### Description
Instructions for applying patches to the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Configuring the ODBC Driver
### Description
Detailed configuration options for the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Configure the ODBC Driver
### Description
General steps for configuring the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
## Configure the Global DSN Default
### Description
How to set
```
--------------------------------
### C# .NET Web Service Integration Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/CabrilloNowApp-client/concept/cabrillo-nowapp-namespace
Tutorials and code examples for integrating with ServiceNow web services using C# and .NET. Covers configuring C# with .NET, calling web services in Visual Studio, and using service/web references.
```C#
// Example using a service reference in a C# integration
// (Actual code would be generated by Visual Studio)
```
```C#
// Example using a web reference in a C# integration
// (Actual code would be generated by Visual Studio)
```
```C#
// C# integration source code example
// (Detailed source code would be provided in the tutorial)
```
--------------------------------
### RESTAPIResponseStream - writeStream (Scoped Applications)
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/ScriptableServiceResponseStreamWriter/concept/c_ScriptableServiceRespStreamWriter
Example of using GlideSysAttachment to get an attachment stream and write it to the response stream for scoped applications.
```APIDOC
## POST /api/example (Scoped Applications)
### Description
This endpoint demonstrates how to retrieve an attachment using GlideSysAttachment and write its content stream to the response for scoped applications.
### Method
POST
### Endpoint
/api/example
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```javascript
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
response.setContentType('application/json');
response.setStatus(200);
var gsa = new GlideSysAttachment();
var attachmentStream = new gsa.getContentStream();
var writer = response.getStreamWriter();
writer.writeStream(attachmentStream);
})(request, response);
```
### Response
#### Success Response (200)
- **attachmentStream** (Object) - The content stream of the attachment.
#### Response Example
(Binary stream of the attachment)
```
--------------------------------
### C# .NET SOAP Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MobileSDKiOS/NowWebViewControllerDelegate/concept/NWViewControllerDelegateiOSProtocol
Demonstrates how to consume ServiceNow SOAP web services from a C# .NET application. Includes steps for configuring with .NET, using service/web references, and sample source code.
```csharp
// Example: Using a service reference in C#
using (var client = new ServiceNowSoapClient())
{
var request = new InsertRequest { Record = new Incident { ShortDescription = "New .NET Incident" } };
var response = client.Insert(request);
// Process response...
}
```
--------------------------------
### Scripted REST API Example - Script Samples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideSecureRandomUtilScoped/concept/c_GlideSecureRandomUtilScopedAPI
Provides script samples for common use cases within Scripted REST APIs, demonstrating how to handle requests, process data, and formulate responses. These examples serve as a starting point for custom API development.
```javascript
// Example: Get all active users
var users = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('active', true);
gr.query();
while (gr.next()) {
users.push({
sys_id: gr.getUniqueValue(),
name: gr.getValue('name'),
email: gr.getValue('email')
});
}
this.response.setBody(users);
```
--------------------------------
### Perl Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/ProducerV2/concept/ProducerV2ScopedAPI
Code examples demonstrating how to use Perl to create web services clients for interacting with ServiceNow.
```perl
# Example for Perl web services client
# Placeholder for actual Perl code
print "Perl web services client example\n";
```
--------------------------------
### Python Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideEmailOutboundScoped/concept/c_GlideEmailOutboundScopedAPI
Offers examples for building web services clients in Python to connect with ServiceNow.
```Python
This is a placeholder for actual Python code examples for web services clients.
```
--------------------------------
### Scripting for SOAP
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideSecureRandomUtilScoped/concept/c_GlideSecureRandomUtilScopedAPI
Examples and guides for scripting outbound SOAP messages, including direct calls, asynchronous operations, and MID Server integration.
```APIDOC
## Scripting Outbound SOAP
### Description
This section details how to script outbound SOAP messages for dynamic interactions, including previewing scripts, direct execution, asynchronous calls, and MID Server integration.
### Methods
- `Preview a SOAP message script`
- `Direct SOAPMessageV2 example`
- `Asynchronous SOAPMessageV2 example`
- `SOAPMessageV2 MID server example`
- `Recordless SOAPMessageV2 example`
```
--------------------------------
### ODBC Driver for Data Sources
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MobileScriptIncludeCaller/concept/MobileScriptInclCallerClientAPI
Guide on creating data sources from other applications using the ODBC driver, including installation, configuration, and testing.
```APIDOC
## Create Data Sources from Other Apps Using ODBC Driver
### Description
This section details the process of using the ODBC driver to create data sources that connect to external applications, covering setup, configuration, testing, and troubleshooting.
### Getting Started with ODBC
#### Create an ODBC User Account and Assign the odbc Role
* **Purpose**: Steps to create a user account with the necessary 'odbc' role for ODBC access.
#### Define an ACL Rule for the odbc Role
* **Purpose**: Configuring Access Control List (ACL) rules to grant permissions for the 'odbc' role.
### Installing the ODBC Driver
#### ODBC Driver Installation Requirements and Supported Software
* **Purpose**: Lists the prerequisites and compatible software for installing the ODBC driver.
#### Download and Install the ODBC Driver
* **Purpose**: Step-by-step instructions for downloading and installing the ODBC driver.
#### Upgrade the ODBC Driver
* **Purpose**: Procedures for updating an existing ODBC driver installation.
#### Install an ODBC Driver Patch
* **Purpose**: How to apply patch updates to the ODBC driver.
### Configuring the ODBC Driver
#### Configure the ODBC Driver
* **Purpose**: General steps for configuring the ODBC driver settings.
#### Configure the Global DSN Default
* **Purpose**: Setting default configurations for Data Source Names (DSNs).
#### Create a New DSN
* **Purpose**: Process for creating a new DSN entry to connect to a data source.
#### Specify a Connection String
* **Purpose**: How to define the connection string used by the ODBC driver.
#### Configure the Logging Level of the ODBC Driver
* **Purpose**: Setting the verbosity level for ODBC driver logs.
#### Configure the ODBC Driver for Large Data Sets
* **Purpose**: Optimizing the driver configuration for handling large volumes of data.
#### Configure ODBC to Use Proxy Servers
* **Purpose**: Setting up the ODBC driver to connect through a proxy server.
#### Setting ODBC Properties
* **Purpose**: Overview of various ODBC driver properties and their configurations.
### Test the ODBC Driver
#### Generate Logs for Debugging
* **Purpose**: How to generate detailed logs for troubleshooting ODBC driver issues.
#### Test a Query
* **Purpose**: Running sample queries to verify the ODBC driver's connectivity and functionality.
#### ODBC Troubleshooting
* **Purpose**: Common issues and solutions related to ODBC driver usage.
### ODBC Behavior
#### Increase the Field Length in SQL Queries
* **Purpose**: Adjusting SQL query parameters to accommodate larger field lengths.
### ODBC and Client Applications
#### Use Interactive SQL with ODBC
* **Purpose**: Guide on using Interactive SQL (ISQL) with the configured ODBC data sources.
* **Specify the Maximum Number of Rows Returned**: How to limit the number of rows returned by queries in ISQL.
* **SQL Support**: Information on the SQL dialect and features supported by the ODBC driver.
```
--------------------------------
### OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/OrderUtil/concept/OrderUtilScopedAPI
Part of a tutorial series: create an OAuth 2.0 provider and associated profile.
```APIDOC
## OAuth 2.0 Tutorial - Create an OAuth Provider and Profile
### Description
Guides users through creating a custom OAuth 2.0 provider and its corresponding profile within the ServiceNow instance.
### Method
N/A (Tutorial Step)
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```
--------------------------------
### ODBC Driver Integration
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/Interaction/concept/InteractionScopedAPI
Comprehensive guide on creating data sources from other applications using the ODBC driver, including installation, configuration, and testing.
```APIDOC
## Create Data Sources from Other Apps Using ODBC Driver
### Description
Guides on integrating external data sources using the ODBC driver.
### Method
N/A
### Endpoint
N/A
### Sub-sections
* Getting Started with ODBC
* Create an ODBC user account and assign the odbc role
* Define an ACL rule for the odbc role
* Installing the ODBC Driver
* ODBC driver installation requirements and supported software
* Download and install the ODBC driver
* Upgrade the ODBC driver
* Install an ODBC driver patch
* Configuring the ODBC Driver
* Configure the ODBC driver
* Configure the global DSN default
* Create a new DSN
* Specify a connection string
* Configure the logging level of the ODBC driver
* Configure the ODBC driver for large data sets
* Configure ODBC to use proxy servers
* Setting ODBC properties
* Test the ODBC Driver
* Generate logs for debugging
* Test a query
* ODBC troubleshooting
* ODBC Behavior
* Increase the field length in SQL queries
* ODBC and Client Applications
* Use Interactive SQL with ODBC
* Specify the maximum number of rows returned
* SQL support
```
--------------------------------
### Python Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/MLSolutionUtil/concept/MLSolutionUtilAPI
Examples of using Python to create a web services client for interacting with ServiceNow.
```Python
# Python web services client examples
```
--------------------------------
### Outbound SOAP Video Tutorial
Source: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/OrderUtil/concept/OrderUtilScopedAPI
A video tutorial covering the essentials of outbound SOAP web services.
```APIDOC
## Outbound SOAP Video Tutorial
### Description
A video resource providing a visual walkthrough of concepts and procedures related to outbound SOAP web services.
### Method
N/A (Video Resource)
### Endpoint
N/A
### Parameters
N/A
### Request Example
N/A
### Response
N/A
```