ServiceNow.Core
0.8.1
See the version list below for details.
dotnet add package ServiceNow.Core --version 0.8.1
NuGet\Install-Package ServiceNow.Core -Version 0.8.1
<PackageReference Include="ServiceNow.Core" Version="0.8.1" />
paket add ServiceNow.Core --version 0.8.1
#r "nuget: ServiceNow.Core, 0.8.1"
// Install ServiceNow.Core as a Cake Addin #addin nuget:?package=ServiceNow.Core&version=0.8.1 // Install ServiceNow.Core as a Cake Tool #tool nuget:?package=ServiceNow.Core&version=0.8.1
Service Now Fluent Api
Easy to connect, and interact with Service Now Api
⚗ This library is in beta state, feel free to test and contribute
Description
Make request using fluent api!
- 🧰 Easy to use, based on the config file it connects and authenticate without one line of code
- 🔑 Typed data, you can use properties to manipulate and restrict requests
- 🛠 Typed properties can be used in Selects, Queries, Ordering...
- 🧩 Auto serialize/deserialize included
- 🎲 Generic Json Elements available as responses
- 📑 Methods and classes have documentation comments, get feedback as you type
- 🗜 Compress requests by default
- 👓 Extensions methods to change and get data from generic responses, log and much more...
Dependencies
- .Net Core 3.1
- .Net Framework 4.6.1
Installing
- Install the package.
- Set an appsettings.json with correct connection values.
- The library check if scope has and .default or not to define how it will get access tokens
- You can use Credentials or Client Secrets for daemon applications
- Create an instance of ServiceNow.
- Create an instance of a Table, (typed or not).
- Configure the request as you like.
- make the request with ToListAsync.
Basic Examples
- Typed (Create any class derived from ServiceNowBaseModel class, so we have an Id Guid)
//Creating an ServiceNow instance
var ServiceNow = new ServiceNow(config);
//Creating an table instance
var usersTable = ServiceNow
.UsingTable<User>("sys_user")
.Limit(2)
.WithQuery(x => $"{x.Name} like Branco and {x.Country} = BR");
//Getting data
var users = await usersTable.ToListAsync();
while (users.Count > 0)
{
foreach (var user in users)
Console.WriteLine(user.ToString());
//Next Request will get the next chunk of data
users = await usersTable.ToListAsync();
}
- Not typed
var usersTableNotTyped = ServiceNow
.UsingTable("sys_user")
.Limit(2)
.WithQuery("name like Branco and country = BR");
var usersNotTyped = await usersTableNotTyped.ToListAsync();
while (usersNotTyped.Count > 0)
{
usersNotTyped.ForEach(userNotTyped => userNotTyped.Display());
usersNotTyped = await usersTableNotTyped.ToListAsync();
}
- Changing not typed Data
//Creating a table instance
var incidentsTableNotTyped = ServiceNow
.UsingTable("incident")
.Limit(10);
//Getting data
var incidentsNotTyped = await incidentsTableNotTyped
.Select(new[] { "sys_id", "short_description" })
.WithQuery("short_description like some nice")
.OrderBy("sys_id")
.ToListAsync();
//Updating
incidentsNotTyped.ForEach(async incident =>
{
Guid id = new Guid(incident.GetProperty("sys_id").ToString());
ExpandoObject inc = incident.ToObject();
inc.UpdateProp("short_description", "changed description on non typed value");
var changed = await incidentsTableNotTyped.Update(id, inc);
if (changed)
Console.WriteLine("Incident Changed");
else
Console.WriteLine("Incident NOT Changed");
});
You can create CatalogItem
See Exxon Service Now Docs to learn more
- You must first create an application in studio inside ServiceNow and then:
- Create a catalogItem
- create a flow
var requestCatalog = serviceNow.UsingCatalog<Request>(new Guid("catalogItemIdHere"));
var request = await requestCatalog.Request(new{
varNameHereString = "string",
varNameHereNumber = 10,
varNameHereReference = new Guid(sys_id),
}); ;
You can set custom Serializers (You must set it only once, this is optional)
//AddCustom Custom Serializers to static class used in ServiceNow
JsonConverterOptions.ConfigureCustomSerializers(new[] {
new CustomRequestStateConverter()
});
Default Serializers for Guid and DateTime
When there is no value in the json response (while using not nullable version) it will return:
- new DateTime() "{1/1/0001 12:00:00 AM}"
- Guid.Empty
That happens because ServiceNow not always return null, in those cases it returns an empty string.
Help
- You can open issues to help improve and collaborate with the library.
- Demos included in project (only the console version for now)
Authors
Emerson Bottero Branco DBAM Automation
Version History
- 1.0
- Table Creation
- Select
- Set Headers
- With Query
- Limit
- OrderBy
- OrderByDesc
- ToList
- Get
- Delete
- Create
- Update
- Compression
- Bug fix (authenticate and when token expiries)
- Extensions methods
- More complex console demo examples
- Authentication Improvements
- Working web API demo (unavailable for now)
- Custom Serializers Settings -New JsonConverters for null-able and normal types -New Update method -When writing new Classes don't set sys_id as null -Enum.ToDescription Method -WithQuery with no arguments -ImportSet API -SnowTable Attribute in classes (remove the need to pass table name as argument in WithTable methods)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.Configuration.Json (>= 5.0.0)
- Microsoft.Identity.Client (>= 4.31.0)
- Microsoft.Identity.Web (>= 1.11.0)
- Polly (>= 7.2.2)
-
.NETFramework 4.7.2
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.Configuration.Json (>= 5.0.0)
- Microsoft.Identity.Client (>= 4.31.0)
- Microsoft.Identity.Web (>= 1.11.0)
- Polly (>= 7.2.2)
-
net5.0
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.Configuration.Json (>= 5.0.0)
- Microsoft.Identity.Client (>= 4.31.0)
- Microsoft.Identity.Web (>= 1.11.0)
- Polly (>= 7.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.6 | 110 | 10/22/2024 |
1.1.5 | 317 | 6/28/2024 |
1.1.4 | 470 | 2/29/2024 |
1.1.3 | 224 | 2/5/2024 |
1.1.2 | 104 | 2/4/2024 |
1.1.1 | 110 | 1/21/2024 |
1.1.0 | 178 | 1/7/2024 |
1.0.1 | 1,551 | 7/7/2022 |
1.0.0 | 531 | 6/26/2022 |
0.8.8 | 546 | 4/10/2022 |
0.8.7 | 647 | 2/9/2022 |
0.8.6 | 418 | 2/7/2022 |
0.8.5 | 642 | 2/2/2022 |
0.8.3 | 245 | 1/13/2022 |
0.8.2 | 263 | 1/12/2022 |
0.8.1 | 442 | 1/11/2022 |
0.8.0 | 460 | 1/11/2022 |
Authentication , Exceptions, Log, Compression improvements
New JsonConverters for nullable and normal types
New Update method
When writing new Classes don't set sys_id as null
Enum.ToDescription Method
WithQuery with no arguments
ImportSet API
pagination auto-reset on WithQuery or 0 results
added logger option
add import set response