Skip to main content

Web API

info

The data and actions exposed through these services are designed for internal use by Dime.Scheduler, and may change at any time.

Web API

RESTful services are at the developer's disposal to interact with Dime.Scheduler directly. Given the right user actions (i.e. the Developer user action) and roles, users will have access to an extra menu option:

Menu

The landing page returns the list of all endpoints, categorized by resource:

Web API endpoints

Each endpoint can be inspected, revealing all the details about it. It even includes a sample response in JSON and XML:

Web API endpoints

With just one glance, developers get the full picture of what is expected to make a valid HTTP request:

  • HTTP verb
  • Required parameters
  • Response formats
  • Response information, including property names and their data types.

Authentication

Any developer worth its salt will understand that the web APIs are protected resources. Users need to authenticate themselves before they can use the web API. Below is an example of how that can be achieved:


var client = new RestClient("http://mydime.scheduler/token");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("content-length", "70");
request.AddHeader("accept-encoding", "gzip, deflate");
request.AddHeader("Host", "dev02.dimescheduler.com:8001");
request.AddHeader("Postman-Token", "062cdb02-aac8-4a9f-9c96-b451ee38afe7,192dc92a-0fc1-46b9-aa49-7a7a949b0c18");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("User-Agent", "PostmanRuntime/7.11.0");
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("undefined", "grant_type=password&username=MyUser&password=MyPassword&=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Three parameters are required in the form:

  • grant_type: The value needs to be 'password'
  • username: The user's e-mail
  • password: The password

The response of this POST request should then be used for all subsequent requests, as the response contains the bearer token:

{
"access_token": "MySecurityToken",
"token_type": "bearer",
"expires_in": 1209599,
"issued": "Mon, 03 Jun 2019 06:59:50 GMT",
"expires": "Mon, 17 Jun 2019 06:59:50 GMT"
}

Note: the response data format can be changed to XML, if required.

Just like any other user in Dime.Scheduler, authorization is applied to every request, even if that request is done programmatically.

Retrieving and manipulating data

Any programming language, tool or software that is able to do web requests will be able to use these services. Here are some examples that fetch the countries:

cURL:


curl -X GET \
http://mydime.scheduler/api/Countries/Get \
-H 'Accept: */*' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Host: mydime.scheduler' \
-H 'User-Agent: PostmanRuntime/7.11.0' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'accept-encoding: gzip, deflate' \
-H 'authorization: Bearer MySecurityToken \
-H 'cache-control: no-cache'

Same example but in C#:

var client = new RestClient("mydime.scheduler/api/Countries/Get");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("accept-encoding", "gzip, deflate");
request.AddHeader("Host", "mydime.scheduler");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "*/*");
request.AddHeader("User-Agent", "PostmanRuntime/7.11.0");
request.AddHeader("X-Requested-With", "XMLHttpRequest");
request.AddHeader("authorization", "Bearer MySecurityToken");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);