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

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;
 }
 }
 }

Last updated