### Configure C# with .NET Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/CatalogSearchScoped/concept/c_CatalogSearchScoped
Guidance on configuring a C# project within the .NET framework to interact with web services. This includes setting up the project and understanding necessary namespaces.
```C#
// Ensure your project references:
// System.Web.Services
// System.Net.Http (for newer .NET Core/5+)
// For WCF services (often used in .NET):
// Add a Service Reference in Visual Studio to your WSDL endpoint.
// For REST APIs:
// Use HttpClient from System.Net.Http.
// Example using HttpClient for a REST API call (conceptual):
// using (var client = new HttpClient()) {
// client.BaseAddress = new Uri("https://yourinstance.service-now.com/");
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes("username:password")));
// var response = await client.GetAsync("api/now/table/incident");
// response.EnsureSuccessStatusCode();
// var responseBody = await response.Content.ReadAsStringAsync();
// Console.WriteLine(responseBody);
// }
```
--------------------------------
### Retrieve Install Base Items with cURL
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-rest/concept/integrations-api
This cURL example demonstrates how to fetch a single install base item starting from a specific offset. It utilizes the GET method and specifies the desired output format as JSON. Authentication is handled via basic HTTP authentication.
```curl
curl "https://instance.servicenow.com/api/sn_install_base/v1/integrations/installbaseitems?sysparm_limit=1&sysparm_offset=5" \
--request GET \
--header "Accept:application/json" \
--user 'username':'password'
```
--------------------------------
### C# .NET Web Services Client Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/NameValuePairs/concept/c_NameValuePairsAPI
Illustrates how to configure and call a web service using C# with .NET, including using service and web references in Visual Studio.
```csharp
// Example of adding a service reference in Visual Studio
// Right-click on 'Connected Services' -> Add Service Reference -> Advanced -> Discover -> Paste WSDL URL
// Example of calling a web service method
/*
using YourServiceNamespace;
public class CSharpIntegration {
public void CallService() {
MyServiceClient client = new MyServiceClient(); // Replace with your service client name
string result = client.GetResponse("Test Input");
Console.WriteLine(result);
}
}*/
```
--------------------------------
### ServiceNow Fluent - Mobile SDK Developer Guide - iOS
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/TransformPartScoped/concept/TransformPartScopedAPI
Guides for using the ServiceNow Mobile SDK for iOS, including architecture and getting started.
```APIDOC
## ServiceNow Fluent - Mobile SDK Developer Guide - iOS
### Description
Guides for using the ServiceNow Mobile SDK for iOS, including architecture and getting started.
### Sections
#### NowSDK architecture
#### Get started with Mobile SDK - iOS
```
--------------------------------
### Python Client Examples (SOAP)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/guides/mobile_sdk/mobile_sdk-android/reference/mobsdk-and-display-web-pages
Provides examples of how to use Python to call ServiceNow SOAP web services, demonstrating data retrieval with basic authentication.
```python
# Example: Python client using zeep library
from zeep import Client
from zeep.wsse import UsernameToken
wsdl = 'https://yourinstance.service-now.com/incident.do?WSDL'
client = Client(wsdl, wsse=UsernameToken('your_username', 'your_password'))
# Example: Inserting a record
response = client.service.insert(
{'short_description': 'New Incident from Python', 'caller_id': 'user_sys_id'}
)
# print(response)
# Example: Getting records
response_get = client.service.getRecords(query='active=true', limit=10)
# print(response_get)
```
--------------------------------
### Start and End Tour
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/guided_tours/concept/guided_toursAPI
Provides examples for starting a tour and ending it immediately after, including error handling and callback functions.
```APIDOC
## POST /websites/servicenow_bundle_yokohama-api-reference
### Description
Starts a specific guided tour and immediately ends it. This is useful for testing or triggering specific tour states. Includes a callback function to handle potential errors or success.
### Method
POST
### Endpoint
/websites/servicenow_bundle_yokohama-api-reference
### Parameters
#### Path Parameters
- **tourId** (string) - Required - The unique identifier of the tour to start.
- **stepNum** (integer) - Required - The starting step number for the tour.
#### Request Body
- **callbackFunction** (function) - Required - A function to be called upon completion or error of the startTour operation.
### Request Example
```javascript
//create a callback function to end the tour if it starts correctly
var cbFunction = function(err) {
if (err) {
console.log('Error Occurred');
}
else {
// tour has started so we can call endTour
top.NOW.guided_tours.api.endTour();
}
}
//calling the startTour method so that we can end the tour as soon as it starts
top.NOW.guided_tours.api.startTour('a297e04b732313007077edcc5ef6a780', 2, cbFunction);
```
### Response
#### Success Response (200)
- **message** (string) - Confirmation message indicating the tour was initiated.
#### Response Example
```json
{
"message": "Tour started successfully."
}
```
```
--------------------------------
### C# .NET Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-soap/reference/createSOAPwebserviceStaticWSDL
This documentation covers creating client applications in C# using the .NET framework to consume ServiceNow web services. It details configuration steps, using service references in Visual Studio, and provides integration source code examples.
```csharp
// Example: Using a service reference in C# .NET
// Assuming 'ServiceReferenceName' is the name of your service reference
// using ServiceNow.ServiceReferenceName;
//
// // Create an instance of the ServiceNow client
// ServiceNowClient client = new ServiceNowClient();
//
// // Example: Retrieving records (using a hypothetical method)
// // QueryFilter filter = new QueryFilter { Field = "active", Operator = "=", Value = "true" };
// // Incident[] incidents = client.GetRecords("incident", new string[] { "number", "short_description" }, filter, 10);
// // foreach (var inc in incidents) {
// // Console.WriteLine($"Incident: {inc.number} - {inc.short_description}");
// // }
//
// // Example: Creating a new record
// // Incident newIncident = new Incident
// // {
// // ShortDescription = "C# .NET Example",
// // Description = "Created via C# client",
// // Priority = "1"
// // };
// // string sysId = client.Insert("incident", newIncident);
// // Console.WriteLine($"New incident created with sys_id: {sysId}");
```
```csharp
// Example: Using a web reference in C# .NET
// Assuming 'WebReferenceName' is the name of your web reference
// using ServiceNow.WebReferenceName;
//
// // Create an instance of the web service
// YourWebServiceNameSoap service = new YourWebServiceNameSoap();
//
// // Set endpoint URL if needed
// // service.Url = "https://yourinstance.service-now.com/your_service.do?WSDL";
//
// // Example: Calling a specific SOAP operation (e.g., insert)
// // GlideRecord incident = new GlideRecord();
// // incident.short_description = "C# Web Reference Example";
// // incident.priority = "1";
// // string result = service.insert("incident", incident);
// // Console.WriteLine($"Insert result: {result}");
```
```csharp
// Example: C# integration source code snippet
// This is a conceptual example and would require specific ServiceNow API knowledge and generated client code.
/*
using System;
using System.Net;
using System.Text;
using System.Xml.Linq;
public class ServiceNowCSharpClient
{
private string _instanceUrl;
private string _username;
private string _password;
public ServiceNowCSharpClient(string instanceUrl, string username, string password)
{
_instanceUrl = instanceUrl;
_username = username;
_password = password;
}
public string InsertRecord(string tableName, string xmlPayload)
{
string endpoint = $"{_instanceUrl}/{tableName}.do?SOAP";
string soapAction = $"http://www.service-now.com/insert";
// Construct the SOAP request XML (this is a simplified example)
string soapRequest = $"\n\n \n \n \n {xmlPayload}\n \n \n \n";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);
request.Headers.Add("SOAPAction", soapAction);
request.ContentType = "text/xml;charset=UTF-8";
request.Method = "POST";
// Basic Authentication
request.Credentials = new NetworkCredential(_username, _password);
byte[] byteData = UTF8Encoding.UTF8.GetBytes(soapRequest);
request.ContentLength = byteData.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(byteData, 0, byteData.Length);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (var streamReader = new System.IO.StreamReader(response.GetResponseStream()))
{
string responseXml = streamReader.ReadToEnd();
// Parse responseXml to extract the sys_id or status
return responseXml; // Placeholder
}
}
}
// Add methods for update, delete, get, etc.
}
*/
```
--------------------------------
### Path Parameters GET Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/custom-web-services/reference/r_ScriptedRESTServiceScriptExamples
This example demonstrates how to retrieve path parameter values from an incoming REST API request.
```APIDOC
## GET /scripted-api/example/path-params/{id}
### Description
Retrieves path parameters from the request URI.
### Method
GET
### Endpoint
/scripted-api/example/path-params/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The identifier for the resource.
### Request Example
```
GET /scripted-api/example/path-params/12345
```
### Response
#### Success Response (200)
- **uri** (string) - The full request URI.
- **url** (string) - The request URL.
- **path_params** (object) - An object containing key-value pairs of the path parameters.
- **path.id** (string) - The value of the 'id' path parameter.
#### Response Example
```json
{
"uri": "/scripted-api/example/path-params/12345",
"url": "/scripted-api/example/path-params/12345",
"path_params": {
"id": "12345"
},
"path.id": "12345"
}
```
```
--------------------------------
### Query Parameters GET Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/custom-web-services/reference/r_ScriptedRESTServiceScriptExamples
This example demonstrates how to retrieve query parameter values from an incoming REST API request.
```APIDOC
## GET /scripted-api/example/query-params
### Description
Retrieves query parameters from the request URI.
### Method
GET
### Endpoint
/scripted-api/example/query-params
### Parameters
#### Query Parameters
- **X-Custom** (string) - Optional - A custom header to demonstrate header retrieval.
### Request Example
```
GET /scripted-api/example/query-params?param1=value1¶m2=value2
```
### Response
#### Success Response (200)
- **uri** (string) - The full request URI.
- **url** (string) - The request URL.
- **queryParams** (object) - An object containing key-value pairs of the query parameters.
- **customHeader** (string) - The value of the 'X-Custom' header.
#### Response Example
```json
{
"uri": "/scripted-api/example/query-params?param1=value1¶m2=value2",
"url": "/scripted-api/example/query-params",
"queryParams": {
"param1": "value1",
"param2": "value2"
},
"customHeader": "some_value"
}
```
```
--------------------------------
### C# .NET Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/outbound-soap/reference/r_OutboundSOAPVideoTutorial
Demonstrates how to consume web services using Microsoft .NET technologies. Covers configuration, using service and web references, and integration.
```C#
// Configure C sharp with .NET
// Example configuration code
```
```C#
// Call a web service in visual studio .NET
// Example code for calling a web service
```
```C#
// Use a service reference in a C Sharp integration
// Code utilizing a service reference
```
```C#
// Use a web reference in a C Sharp integration
// Code utilizing a web reference
```
```C#
// C Sharp integration source code
// Complete source code for C# integration
```
```C#
// Troubleshoot a null response in a C Sharp integration
// Code for handling null responses
```
--------------------------------
### C# .NET Web Service Client Example (Use Web Reference)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/MobileSDKAndroid/NowWebService/concept/NowWebServiceAndroidAPI
Illustrates how to use a web reference in C# .NET to consume a web service.
```csharp
MyWebService.Service1SoapClient client = new MyWebService.Service1SoapClient();
var result = client.InsertRecord(new MyWebService.Record {
ShortDescription = "Insert from C# WebRef"
});
```
--------------------------------
### Get Check List Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/AccCheckDefsAPI/concept/AccCheckDefsAPIAPIScoped
This example demonstrates how to retrieve a list of check definitions, optionally including parameter values.
```APIDOC
## GET /websites/servicenow_bundle_yokohama-api-reference/checks
### Description
Retrieves a list of check definitions, with options to filter by name and include parameter details.
### Method
GET
### Endpoint
/websites/servicenow_bundle_yokohama-api-reference/checks
### Query Parameters
- **encQuery** (String) - Optional - An encoded query string to filter check definitions (e.g., "nameSTARTSWITHchecks_").
- **limit** (Number) - Optional - The maximum number of check definitions to return.
- **withParams** (Boolean) - Optional - If true, includes parameter details in the response.
### Response
#### Success Response (200)
- **checkDefs** (Array) - An array of check definition objects. Each object may contain:
- **name** (String) - The name of the check definition.
- **command** (String) - The command executed by the Agent Client Collector.
- **plugins** (Array) - A list of associated Agent Client Collector plugins.
- **timeout** (Number) - The timeout in seconds for the check.
- **proxy_valid** (Boolean) - Whether the check definition policy is set to work as a proxy.
- **background** (Boolean) - Whether this check definition is a background check.
- **check_type** (String) - The type of check (e.g., "Events", "Metrics").
- **check_group** (String) - The group specified for this check definition.
- **sys_id** (String) - The system ID of the check definition.
- **params** (Array) - An array of parameter objects (if withParams is true).
- **secure_params** (Array) - An array of secure parameter objects (if withParams is true).
#### Response Example
```json
[
{
"name": "checks_api_test",
"command": "echo hello",
"plugins": [],
"timeout": 9,
"proxy_valid": true,
"background": false,
"check_type": "TestCheck",
"check_group": "computer",
"sys_id": "7f1f9026dba530106f4810284b96194f",
"params": [],
"secure_params": [
{
"name": "check_api_test_check_secure_param2",
"active": true,
"order": 2,
"sys_id": "2d30a066dba530106f4810284b9619c1"
},
{
"name": "check_api_test_check_secure_param1",
"active": true,
"order": 100,
"sys_id": "4c20a066dba530106f4810284b9619a8"
}
]
},
{
"name": "checks_api_test222",
"command": "echo hello1212121",
"plugins": [],
"timeout": 60,
"proxy_valid": true,
"background": false,
"check_type": "TestCheck",
"check_group": "computer",
"sys_id": "99e12466dba530106f4810284b961976",
"params": [
{
"name": "check_api_test_check_param_222",
"active": true,
"mandatory": false,
"default_value": "test_test_test",
"sys_id": "44026466dba530106f4810284b9619b2"
}
],
"secure_params": []
}
]
```
```
--------------------------------
### Script Include GET Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/custom-web-services/reference/r_ScriptedRESTServiceScriptExamples
This example demonstrates how to use a script include to generate the API response, promoting code reusability and maintainability.
```APIDOC
## GET /scripted-api/example/script-include
### Description
Utilizes a script include ('SampleDataUtil') to fetch and return sample JSON data.
### Method
GET
### Endpoint
/scripted-api/example/script-include
### Parameters
None
### Request Example
```
GET /scripted-api/example/script-include
```
### Response
#### Success Response (200)
- **responseObj** (object) - The JSON object returned by the SampleDataUtil script include.
#### Response Example
```json
{
"message": "Sample data from script include"
}
```
```
--------------------------------
### C# .NET Web Services Client Example (ServiceNow)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/LeadAPIValidationUtilOOB/concept/LeadAPIValidationUtilOOBAPI
Illustrates how to use Microsoft .NET to create a web services client for ServiceNow. Includes guidance on using service or web references.
```csharp
// Example: Using a service reference in C#
// Add a service reference to your ServiceNow WSDL in Visual Studio
// using YourServiceNamespace;
// ...
// YourServicePortClient client = new YourServicePortClient();
// client.ClientCredentials.UserName.UserName = "user";
// client.ClientCredentials.UserName.Password = "password";
// var response = client.insert(requestObject);
```
```csharp
// Example: C# integration source code snippet
// Assuming 'client' is an initialized web service client
// ...
// var insertResult = client.insert(incidentData);
// if (insertResult.result) {
// Console.WriteLine("Incident inserted successfully: " + insertResult.sys_id);
// } else {
// Console.WriteLine("Error inserting incident: " + insertResult.errorMsg);
// }
```
--------------------------------
### Java Apache Axis2 Web Service Client Example (Update)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/PSBScratchpadUtil/concept/PSBScratchpadUtilScopedAPI
Shows a Java Apache Axis2 client example for updating records in ServiceNow using SOAP. Similar setup to the insert example.
```java
// Assuming generated stub classes from WSDL
YourServiceStub stub = new YourServiceStub();
YourServiceUpdateRequest request = new YourServiceUpdateRequest();
// Set request parameters for update operation (sys_id, fields)
// ...
YourServiceUpdateResponse response = stub.update(request);
// Process response...
```
--------------------------------
### C# .NET Web Services Client Example (Use Service Reference)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/RegressionSolutionStore/concept/RegressionSolutionStoreAPI
Shows how to configure and use a service reference in C# with .NET to interact with a web service, covering integration setup.
```csharp
// Add Service Reference in Visual Studio
// Right-click on project -> Add -> Service Reference
// Enter the WSDL URL or file path
// Example usage after adding the reference
// using YourServiceNameReferenceNamespace;
// YourServiceSoapClient client = new YourServiceSoapClient();
// Construct the request object
// InsertRequest request = new InsertRequest
// {
// TableName = "problem",
// Values = new NameValue[]
// {
// new NameValue { Name = "short_description", Value = "C# Service Reference Test" }
// }
// };
// Call the web service method
// InsertResponse response = client.Insert(request);
// Process the response
// Console.WriteLine($"Record inserted with sys_id: {response.SysId}");
```
--------------------------------
### C# .NET Web Service Integration Examples
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/TopicUtilOOB/concept/TopicUtilOOBAPIScoped
Guides through configuring C# with .NET to call web services, using service or web references in Visual Studio. Includes source code examples for integration.
```csharp
// Using a Service Reference:
// Add a Service Reference to your ServiceNow WSDL in Visual Studio.
// Example:
// ServiceNowService.YourServiceNowClient client = new ServiceNowService.YourServiceNowClient();
// ServiceNowService.Incident incident = new ServiceNowService.Incident();
// incident.short_description = "Incident from C# Service Reference";
// client.insert("incident", incident);
// Using a Web Reference:
// Add a Web Reference to your ServiceNow WSDL in Visual Studio.
// Example:
// ServiceNowWebReference.YourServiceNowWSSoapClient client = new ServiceNowWebReference.YourServiceNowWSSoapClient();
// ServiceNowWebReference.Incident incident = new ServiceNowWebReference.Incident();
// incident.short_description = "Incident from C# Web Reference";
// client.insert("incident", incident);
// C# integration source code would involve instantiating the client,
// creating request objects, calling the appropriate methods (insert, update, etc.),
// and handling the response.
```
--------------------------------
### Get Started with Mobile SDK - iOS
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-soap/reference/r_StaticWSDLExample
Provides a starting point for using the ServiceNow Mobile SDK in an iOS application. This includes essential setup and configuration steps required before utilizing SDK features.
```swift
// Ensure you have added the ServiceNow SDK as a dependency
// For example, using Swift Package Manager or CocoaPods
import ServiceNowSDK
// In your AppDelegate or relevant class:
func setupServiceNowSDK() {
// Initialize the SDK with your ServiceNow instance name
ServiceNowSDK.initialize(instanceName: "your_instance_name")
// Further configuration can be done here as needed
}
```
--------------------------------
### C# .NET Client Examples for SOAP
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/SummaryTableWriterScriptInclude/concept/c_SummaryTableWriter
Demonstrates how to configure and use C# with .NET to call ServiceNow SOAP web services. Includes examples using service and web references in Visual Studio.
```csharp
// Configure C sharp with .NET
// Placeholder for configuration code
```
```csharp
// Call a web service in visual studio .NET
// Placeholder for calling web service code
```
```csharp
// Use a service reference in a C Sharp integration
// Placeholder for service reference code
```
```csharp
// Use a web reference in a C Sharp integration
// Placeholder for web reference code
```
```csharp
// C Sharp integration source code
// Placeholder for source code
```
--------------------------------
### Python Web Services Client Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/CabrilloNowApp-client/concept/cabrillo-nowapp-namespace
Example code for interacting with ServiceNow web services using Python. This typically involves using libraries like `zeep` for SOAP clients. Requires Python installation and the `zeep` library (`pip install zeep`).
```Python
from zeep import Client
from zeep.wsse import UsernameToken
# Replace with your ServiceNow instance URL and WSDL path
wsdl_url = 'https://YOUR_INSTANCE.service-now.com/incident.do?WSDL'
native_url = 'https://YOUR_INSTANCE.service-now.com/api/now/v1/table/incident'
# Replace with your ServiceNow username and password
username = 'YOUR_USERNAME'
password = 'YOUR_PASSWORD'
try:
# Initialize SOAP client
client = Client(wsdl_url, wsse=UsernameToken(username, password))
# Get the 'insert' operation
insert_operation = client.operations['insert']
# Prepare the incident data
incident_data = {
'number': 'INC0010002',
'short_description': 'Python Insert Test',
'caller_id': 'sys_id_of_caller'
# Add other fields as needed
}
# Call the insert operation
result = insert_operation(**incident_data)
print(f"Incident inserted with sys_id: {result}")
except Exception as e:
print(f"An error occurred: {e}")
# Example for REST API using requests library (not included in SOAP snippet but relevant)
# import requests
# headers = {"Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS"}
# payload = {"short_description": "Python REST Test"}
# response = requests.post(native_url, json=payload, headers=headers)
# print(response.json())
```
--------------------------------
### Install Now Assist for Code Generation (ServiceNow)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-rest/concept/remote_help_request-api
Details the steps required to install and configure Now Assist for code generation features within the ServiceNow platform. This involves administrative setup.
```javascript
// Installation is typically done via the ServiceNow App Store or by an administrator.
// It involves installing the relevant Now Assist plugin(s).
// Configuration steps usually follow installation, guided by ServiceNow documentation.
```
--------------------------------
### Mobile SDK Developer Guide - iOS
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/GlideCurrencyValue/concept/GlideCurrencyValueScopedAPI
Documentation for developing with the Mobile SDK for iOS, including NowSDK architecture and getting started instructions.
```APIDOC
## Mobile SDK Developer Guide - iOS
This guide covers the development of iOS applications using the ServiceNow Mobile SDK.
### NowSDK Architecture
Information about the underlying architecture of the NowSDK.
### Get Started with Mobile SDK - iOS
Instructions for setting up and configuring the Mobile SDK for your iOS project.
```
--------------------------------
### C# .NET Web Service Client Example (Service Reference)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/script/client-scripts/concept/c_CatalogClientScriptCreation
Illustrates configuring C# with .NET and using a service reference to call ServiceNow web services.
```C#
// Ensure you have added a Service Reference to your ServiceNow WSDL in Visual Studio.
// This will generate proxy classes based on the WSDL.
using System;
using YourServiceNamespace.ServiceNowIncidentService; // Replace with your actual namespace
public class CSharpIncidentClient
{
public static void CreateIncident(string shortDescription, int priority)
{
// Instantiate the ServiceNow client using the generated proxy class
var client = new IncidentServicePortTypeClient(); // Name might vary based on WSDL import
// Set endpoint address if not configured in app.config/web.config
client.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://your-instance.service-now.com/incident.do?SOAP");
// Configure basic authentication
var httpBehavior = new System.ServiceModel.Description.ClientHttpBehavior();
var credentialCache = new System.Net.CredentialCache();
credentialCache.Add(new Uri("https://your-instance.service-now.com/"), "Basic", new System.Net.NetworkCredential("your_username", "your_password"));
httpBehavior.Credentials = credentialCache;
client.ChannelFactory.Endpoint.Behaviors.Add(httpBehavior);
// Prepare the insert request object (names depend on generated proxy classes)
var insertRequest = new InsertRequest();
insertRequest.insert = new Insert(); // Assuming 'insert' is the operation name
insertRequest.insert.short_description = shortDescription;
insertRequest.insert.priority = priority.ToString(); // Priority might need to be a string
try
{
// Call the insert operation
var response = client.insert(insertRequest);
// Process the response
if (response != null && response.insertResponse != null)
{
Console.WriteLine($"Incident created successfully. Sys ID: {response.insertResponse.sys_id}");
}
else
{
Console.WriteLine("Incident creation failed or returned an unexpected response.");
}
}
catch (System.ServiceModel.FaultException ex)
{
Console.WriteLine($"SOAP Fault: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
finally
{
// Dispose of the client
if (client != null)
{
client.Close();
}
}
}
public static void Main(string[] args)
{
CreateIncident("Test incident from C#", 1);
}
}
```
--------------------------------
### Get Node Name (JavaScript)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/XMLNodeScopedAPI/concept/c_XMLNodeScopedAPI
This example illustrates how to retrieve the name of an XML node. It parses an XML string and then uses `getNodeName()` to get the element's tag name.
```javascript
var xmlString = "" +
" " +
" abcd1234" +
" 1234abcd" +
" another" +
" " +
" 1234" +
"";
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var node = xmlDoc.getNode('//two');
gs.info(node.getNodeName());
```
--------------------------------
### Get Next Scheduled Event Time
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/GlideScheduleScoped/concept/c_GlideScheduleScopedAPI
Calculates and retrieves the next occurrence of a schedule after a given start date. Requires a GlideSchedule object loaded with a sys_id and a GlideDateTime object for the start.
```javascript
var startDate = new GlideDateTime('2014-10-25 08:00:00');
var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', 'UTC');
gs.info(glideSchedule.whenNext(startDate));
```
--------------------------------
### Configure C# with .NET
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/inbound-rest/concept/c_IdentifyReconcileAPI
Guidance on setting up a C# project with .NET to consume ServiceNow web services.
```csharp
// To configure C# with .NET for ServiceNow web services:
// 1. Open your C# project in Visual Studio.
// 2. Right-click on 'Dependencies' or 'Connected Services' in Solution Explorer.
// 3. Select 'Add Service Reference...' or 'Add Connected Service'.
// 4. In the 'Address' field, enter the WSDL URL of the ServiceNow service (e.g., http://your-instance.service-now.com/incident.do?WSDL).
// 5. Click 'Go' and then 'Add'.
// 6. Visual Studio will generate proxy classes for the web service.
// 7. You can then instantiate the generated client and
```
--------------------------------
### GlideURI - Set and Get Query Parameter (Alternative)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/GlideURIGlobal/concept/GlideURIGlobalAPI
Another example of setting and retrieving a query parameter using GlideURI.
```APIDOC
## GlideURI - Set and Get Query Parameter (Alternative)
### Description
Sets and retrieves query parameters using the GlideURI object (alternative implementation).
### Method
N/A - Script Example
### Endpoint
N/A - Script Example
### Parameters
N/A
### Request Body
N/A
### Request Example
```javascript
var gURI = action.getGlideURI();
gURI.set('sysparm_query', 'priority=2^active=true' );
var fileString = gURI.get('sysparm_query');
gs.info(fileString);
```
### Response
N/A - Script Example
```
--------------------------------
### C# .NET Web Service Client Examples
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/ProbeHandlerCim/concept/c_ProbeHandlerCimAPI
This documentation covers integrating with ServiceNow using Microsoft .NET, including configuring C# with .NET, calling web services in Visual Studio, and using service or web references.
```C#
// Example: C# .NET client using a Service Reference
// Assuming 'ServiceNowService.incident' is the generated client class
// ServiceNowService.incidentClient client = new ServiceNowService.incidentClient();
// client.Url = "https://yourinstance.service-now.com/your_soap_service.do";
// ServiceNowService.incident incidentRecord = new ServiceNowService.incident();
// incidentRecord.short_description = "Test Incident from C#";
// Call the insert function
// client.insert(incidentRecord);
```
--------------------------------
### C# Integration Source Code Example (.NET)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/DynamicSchemaAPI/concept/DynamicSchemaAPI
Presents a complete source code example for a C# .NET integration with ServiceNow SOAP web services. This includes setup, request execution, and response handling.
```csharp
// Ensure you have added a service or web reference to your ServiceNow SOAP endpoint.
// Replace YourServiceClient and YourOperation* with your generated types.
using System;
using System.ServiceModel;
public class ServiceNowIntegration
{
public static void CreateIncident(string instanceUrl, string username, string password)
{
try
{
using (var client = new YourServiceClient())
{
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
var incidentRequest = new YourOperationRequest
{
// Populate incident details
parameters = new YourOperationRequestBody
{
short_description = "New incident from C#",
caller_id = "user_sys_id"
}
};
var response = client.yourOperation(incidentRequest);
if (response != null && response.result != null)
{
Console.WriteLine("Incident created successfully. Sys ID: " + response.result.sys_id);
}
else
{
Console.WriteLine("Failed to create incident.");
}
}
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}
}
public static void Main(string[] args)
{
string instanceUrl = "https://yourinstance.service-now.com";
string username = "your_username";
string password = "your_password";
CreateIncident(instanceUrl, username, password);
}
}
```
--------------------------------
### C# .NET Web Services Client Example (Web Reference)
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/SimilaritySolution/concept/SimilaritySolutionAPI
Demonstrates consuming a ServiceNow web service in C# using a web reference in Visual Studio.
```csharp
using System;
public class ServiceNowClient
{
public void UpdateIncident(string sysId, string description)
{
var client = new YourProject.WebReferenceName.ServiceNowSoapPortClient(); // Replace with your actual client name
var incidentUpdate = new YourProject.WebReferenceName.Incident()
{
sys_id = sysId,
description = description
};
var response = client.update(incidentUpdate);
Console.WriteLine("Update response: " + response.status);
}
}
```
--------------------------------
### Python Web Services Client Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/CimProbeResult/concept/c_CimProbeResultAPI
Provides a Python example for consuming SOAP web services, likely using libraries such as `zeep` or `suds`. Shows basic client setup and method invocation.
```python
from zeep import Client
# Define the WSDL URL
wsdl_url = 'http://your.service.endpoint.com?wsdl'
try:
# Create a SOAP client instance
client = Client(wsdl_url)
# Example: Call a web method
# result = client.service.YourMethodName(
# param1='value1',
# param2=123
# )
# Process the result
# print(result)
except Exception as e:
print(f"An error occurred: {e}")
```
--------------------------------
### Mobile SDK Developer Guide
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/rss/concept/c_LimitingResultsWithAView
Documentation for developing mobile applications using the ServiceNow Mobile SDK for Android and iOS. This includes getting started, architecture, and specific implementation details.
```APIDOC
## Mobile SDK Developer Guide
This guide provides information on using the ServiceNow Mobile SDK for both Android and iOS platforms.
### Mobile SDK Architecture
Details about the overall architecture of the NowSDK.
### Get Started with Mobile SDK - Android
Instructions for integrating the Android Mobile SDK into your project.
#### Download and install the Mobile SDK library
Steps to acquire and add the SDK library to your Android project.
#### Install and configure the Mobile SDK scoped application
Guidance on setting up the ServiceNow scoped application for the Mobile SDK.
#### Configure your project
Steps to configure your Android project to work with the SDK.
#### Configure certificate and create an OAuth Entity
Instructions for setting up authentication using certificates and OAuth.
#### Configure guest user access
How to enable and configure access for guest users.
### Initialize the NowSDK in your application
Code examples and steps to initialize the NowSDK within your Android application.
### Implement Virtual and Live Agent chat
Guidance on integrating chat functionalities.
#### Pass NowChatConfiguration to modify the behavior of NowChat
Details on customizing chat behavior using `NowChatConfiguration`.
### Interact with table data in a ServiceNow instance
How to perform CRUD operations on table data.
#### Configure return results data
Options for configuring the data returned from table operations.
#### Configure field write options
Settings for controlling write access to fields.
#### Paginate return results record sets
Techniques for handling large datasets with pagination.
#### Configure tables to work with guests
Specific configurations for guest access to tables.
### Interact with the public REST API on a ServiceNow instance
How to make calls to the ServiceNow public REST API from your mobile application.
### Retrieve attachments and attachment metadata
Methods for fetching attachments and their associated metadata.
### Display web pages hosted on your ServiceNow instance
Displaying web content from your ServiceNow instance within the mobile app.
### Configure push notifications
Detailed steps for setting up and managing push notifications.
#### Setting up push notifications on your ServiceNow instance
Configuration steps required on the ServiceNow platform.
##### Retrieve the Firebase push server key
How to obtain the necessary Firebase server key.
##### Add a push application record
Creating a record for your push notification application.
##### Add a default push registration
Setting up default registration for push notifications.
##### Add a push notification message content record
Defining the content of push notification messages.
##### Add a push notification message
Creating and sending push notification messages.
##### Modify the push notification
How to update existing push notification configurations or messages.
#### Setting up push notifications in your Android application
Steps to implement push notification handling within your Android app.
### Use NowUIColoring to theme NowWebTheme and NowChatTheme
Customizing the appearance of web views and chat interfaces using `NowUIColoring`.
### Get Started with Mobile SDK - iOS
Instructions for integrating the iOS Mobile SDK into your project.
#### NowSDK architecture
Details about the overall architecture of the NowSDK for iOS.
```
--------------------------------
### Mobile SDK Developer Guide - iOS
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/OnCallEscalationTemplateSNC/concept/OnCallEscalationTemplateSNCAPI
This section provides documentation for the ServiceNow Mobile SDK for iOS, including architecture and getting started.
```APIDOC
## Mobile SDK Developer Guide - iOS
This section provides documentation for the ServiceNow Mobile SDK for iOS, including architecture and getting started.
### NowSDK Architecture
Provides an overview of the NowSDK architecture for iOS.
### Get Started with Mobile SDK - iOS
Guides you through the initial setup and configuration of the Mobile SDK for iOS.
```
--------------------------------
### C# .NET Web Services Client Examples
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/ScriptableDataStream/concept/ScriptableDataStreamAPI
Demonstrates how to consume ServiceNow web services from C# .NET applications, including using service and web references in Visual Studio.
```csharp
// Example: Using a Service Reference in C# .NET
// After adding a service reference to your ServiceNow WSDL in Visual Studio:
/*
using (var client = new ServiceNowClient.YourServiceNowClient()) { // Replace ServiceNowClient.YourServiceNowClient with your actual client class
// Configure authentication if needed (e.g., NetworkCredential)
// client.ClientCredentials.UserName.UserName = "your_username";
// client.ClientCredentials.UserName.Password = "your_password";
// Example: Calling an insert operation (method name depends on your WSDL/service)
var incidentData = new ServiceNowClient.incident(); // Replace with your generated incident object type
incidentData.short_description = "New incident from C#";
incidentData.caller_id = "user_sys_id"; // Replace with actual user sys_id
var result = client.insert(incidentData); // Replace 'insert' with the actual method name
Console.WriteLine($"Incident created with sys_id: {result}");
}
*/
```
```csharp
// Example: Using a Web Reference in C# .NET
// After adding a web reference to your ServiceNow WSDL in Visual Studio:
/*
using (var service = new YourWebReferenceNamespace.ServiceNowSoapService()) { // Replace YourWebReferenceNamespace and ServiceNowSoapService
// Configure authentication if needed
// service.Credentials = new System.Net.NetworkCredential("your_username", "your_password");
// Example: Calling an update operation
var incidentUpdate = new YourWebReferenceNamespace.incident(); // Replace with your generated incident type
incidentUpdate.sys_id = "sys_id_to_update";
incidentUpdate.state = "6"; // Resolved
incidentUpdate.close_notes = "Updated via C# Web Reference";
var updateResponse = service.update(incidentUpdate); // Replace 'update' with the actual method name
if (updateResponse != null && updateResponse.success) { // Assuming response object has a success property
Console.WriteLine("Incident updated successfully.");
} else {
Console.WriteLine("Incident update failed.");
}
}
*/
```
```csharp
// Example: C# Integration Source Code Snippet (Conceptual)
// This represents a simplified structure for a C# integration.
public class ServiceNowIntegration
{
public void CreateIncident(string shortDescription, string callerId)
{
// Assume 'client' is an initialized ServiceNow SOAP client object (either Service or Web Reference)
// ServiceNowClient.YourServiceNowClient client = new ServiceNowClient.YourServiceNowClient();
// client.UseDefaultCredentials = true; // Or Basic Auth
/*
var incident = new ServiceNowClient.incident();
incident.short_description = shortDescription;
incident.caller_id = callerId;
var resultSysId = client.insert(incident);
Console.WriteLine($"Created incident with sys_id: {resultSysId}");
*/
}
public void UpdateIncidentState(string sysId, string newState)
{
// Assume 'client' is an initialized ServiceNow SOAP client object
/*
var incident = new ServiceNowClient.incident();
incident.sys_id = sysId;
incident.state = newState;
client.update(incident);
Console.WriteLine($"Updated incident {sysId} to state {newState}");
*/
}
}
```
--------------------------------
### Basic Header Configuration Example
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/Fetch/concept/Fetch.HeadersAPI
A simple example showing how to set basic headers like 'compression', 'content-type', and 'cookie'. This is a fundamental use case for the Headers API.
```plaintext
compression ==> gzip
content-type ==> application/json
cookie ==> This is a demo cookie
```
--------------------------------
### Scheduled for Future - Example Output
Source: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_reference/GlideScheduleScoped/concept/c_GlideScheduleScopedAPI
Illustrates the output when a schedule is not currently active and the next event is in the future. Shows the milliseconds until the next start time.
```javascript
[Scheduled for future] *** Script: Not currently in schedule *** Script: Next schedule starts in 332894000 milliseconds
```