ServiceNow.Core
1.1.5
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Framework 4.7.2
This package targets .NET Framework 4.7.2. The package is compatible with this framework or higher.
dotnet add package ServiceNow.Core --version 1.1.5
NuGet\Install-Package ServiceNow.Core -Version 1.1.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServiceNow.Core" Version="1.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ServiceNow.Core --version 1.1.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ServiceNow.Core, 1.1.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ServiceNow.Core as a Cake Addin #addin nuget:?package=ServiceNow.Core&version=1.1.5 // Install ServiceNow.Core as a Cake Tool #tool nuget:?package=ServiceNow.Core&version=1.1.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Service Now Fluent API
Easy to connect, and interact with Service Now API
📕 See the Full Documentation
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();
}
Same as above but using Where
//Creating an table instance
var usersTable = ServiceNow
.UsingTable<User>("sys_user")
.Limit(2)
.Where(x => x.Name.Contains("Branco") && x.Country = "BR");
- 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 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 and DateOnly
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
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.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)
-
net6.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.5 | 172 | 6/28/2024 |
1.1.4 | 360 | 2/29/2024 |
1.1.3 | 209 | 2/5/2024 |
1.1.2 | 88 | 2/4/2024 |
1.1.1 | 102 | 1/21/2024 |
1.1.0 | 163 | 1/7/2024 |
1.0.1 | 1,500 | 7/7/2022 |
1.0.0 | 516 | 6/26/2022 |
0.8.8 | 526 | 4/10/2022 |
0.8.7 | 629 | 2/9/2022 |
0.8.6 | 411 | 2/7/2022 |
0.8.5 | 626 | 2/2/2022 |
0.8.3 | 228 | 1/13/2022 |
0.8.2 | 247 | 1/12/2022 |
0.8.1 | 427 | 1/11/2022 |
0.8.0 | 443 | 1/11/2022 |
Feat: AllToListAsync new method