# Using the Web API

The web api service must be first installed and started (see topic [Web Api Service Setup](/apprules-r-documentation/platform/self-hosting/software-installation/webapi.md))

\
The following Postman screens shows how to setup a sample project call using the web API:

![](/files/-MHuuGPGRD2hWI0hJpgt)

![](/files/-MHuuWxub_3PCfuELo71)

![](/files/-MHuu_mHT2X_ebqXKB20)

### 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:

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/creating-and-running-projects/running-projects/web-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
