appRules
Ask or search…
K

Using the Web API

The web api service must be first installed and started (see topic Web Api Service Setup)
The following Postman screens shows how to setup a sample project call using the web API:

Body structure

Connection Params
Description
Organization
The organization. When not specified, Default is used
DatabaseId
The id the project database.
UserId
The user id for running the job
Password
The encrypted user password for running the job.
ApiKey
Security feature, Optional if a webapi key is not specified in the WebApi service config file, Must match the ApiKey on the server if specified - the project will be only run if Apikeys match on client and server
Execution Params
Description
Projectid
The integer id of the project to run
Reference
Optional reference for the job
Interactive
Mode for running the job: false = background (the project is launched only), true = foreground (the api waits for the project to end (used when return arguments are specified -example waiting for a return code to execute another project), Note: Default is false
Arguments
Optional name/value dictionary of arguments for running the job in Json format, leave blank if none (remove the Arguments json)
The following C# shows how to setup a sample project using the web api:
using System;
using System.Collections.Generic;
using System.Configuration;
using Newtonsoft.Json;
using appRulesPortal.WebApi.Client;
using appRulesPortal.WebApi.Params;
namespace SampleWebApi
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main(string[] args)
{
if (args == null)
return 4;
var connectionParams =
new
ConnectionParams();
var executionParams =
new
ExecutionParams();
connectionParams.Organization = args[0]; //Organization (or use * for Default)
connectionParams.DatabaseId = Convert.ToInt32(args[1]); //project database id
connectionParams.UserId = args[2]; //user id
connectionParams.Password = args[3]; //password
executionParams.ProjectId = Convert.ToInt32(args[4]); //project id;
if (args.Length > 5)
{
executionParams.Reference = args[5]; //reference for job (or use * Note: No spaces
if (args.Length > 6)
executionParams.Arguments = (Dictionary<string, object>)JsonConvert.DeserializeObject(args[5],
typeof
(Dictionary<string, object>));
}
var apiKey = ConfigurationManager.AppSettings["ApiKey"];
if(!String.IsNullOrEmpty(apiKey))
connectionParams.ApiKey = apiKey;
var serviceUrl = ConfigurationManager.AppSettings["WebApiUrl"];
if (String.IsNullOrEmpty(serviceUrl))
serviceUrl = "http://localhost:8082/";
var client =
new
PortalClient(serviceUrl); //initialize the url of the WebApi service
//var result = client.Execute(connectionParams, null).Result; //arguments can be null since it is defined in connectionParams.args
client.Execute(connectionParams, executionParams);
return 0;
}
}
}