An API for securitytext.org
How to Build
The generated code uses the Newtonsoft Json.NET NuGet Package. If the automatic NuGet package restore is enabled, these dependencies will be installed automatically. Therefore, you will need internet access for build.
- Open the solution (SecuritytextOrgAPI.sln) file.
- Invoke the build process using
Ctrl+Shift+Bshortcut key or using the
Buildmenu as shown below.
How to Use
The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the MSDN Portable Class Libraries documentation.
The following section explains how to use the SecuritytextOrgAPI library in a new console project.
1. Starting a new project
For starting a new project, right click on the current solution from the solution explorer and choose
Add -> New Project.
Next, choose "Console Application", provide a
TestConsoleProject as the project name and click
2. Set as startup project
The new console project is the entry point for the eventual execution. This requires us to set the
TestConsoleProject as the start-up project. To do this, right-click on the
TestConsoleProject and choose
Set as StartUp Project form the context menu.
3. Add reference of the library project
In order to use the SecuritytextOrgAPI library in the new project, first we must add a projet reference to the
TestConsoleProject. First, right click on the
References node in the solution explorer and click
Next, a window will be displayed where we must set the
SecuritytextOrgAPI.UWP and click
OK. By doing this, we have added a reference of the
SecuritytextOrgAPI.UWP project into the new
4. Write sample code
TestConsoleProject is created, a file named
Program.cs will be visible in the solution explorer with an empty
Main method. This is the entry point for the execution of the entire solution.
Here, you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
How to Test
The generated SDK also contain one or more Tests, which are contained in the Tests project. In order to invoke these test cases, you will need NUnit 3.0 Test Adapter Extension for Visual Studio. Once the SDK is complied, the test cases should appear in the Test Explorer window. Here, you can click Run All to execute these test cases.
API client can be initialized as following.
SecuritytextOrgAPIClient client = new SecuritytextOrgAPIClient();
Get singleton instance
The singleton instance of the
WhoisController class can be accessed from the API Client.
IWhoisController whois = client.Whois;
Query the server for a Domain object
Task<Models.ResponsesQueryModel> CreateApiWhoisQuery(Models.RequestsQueryModel body)
||Body of API request|
var body = new Models.RequestsQueryModel(); Models.ResponsesQueryModel result = await whois.CreateApiWhoisQuery(body);
|Error Code||Error Description|
|500||Internal Server Error|