Worked examples for calling the FRI+ API in Python, JavaScript (Node.js), C# (.NET) and cURL. Each obtains a token and calls the ProcessFatigueRisk endpoint.
Python
import requests
# Configuration
IDENTITY_URL = "https://frmsc-apim-euwest.azure-api.net/connect/token"
API_BASE_URL = "https://frmsc-apim-euwest.azure-api.net"
CLIENT_ID = "your_client_id"
CLIENT_SECRET = "your_client_secret"
def get_token():
"""Obtain an OAuth 2.0 bearer token."""
response = requests.post(IDENTITY_URL, data={
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
}, headers={"Content-Type": "application/x-www-form-urlencoded"})
response.raise_for_status()
return response.json()["access_token"]
def build_roster():
"""Construct a 7-night-shift roster CSV string."""
shifts = [
"J. Williams,03/06/2026,22:00,04/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,04/06/2026,22:00,05/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,05/06/2026,22:00,06/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,06/06/2026,22:00,07/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,07/06/2026,22:00,08/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,08/06/2026,22:00,09/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,09/06/2026,22:00,10/06/2026,06:00,3,1,60,1,360,0,45",
]
return "\r\n".join(shifts)
def call_fri(token, roster_csv):
"""Call the FRI+ API and return the result."""
response = requests.post(
f"{API_BASE_URL}/api/RiskIndexProcessor/ProcessFatigueRisk",
json={"RosterData": roster_csv, "DateFormat": "dmy"},
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
},
)
response.raise_for_status()
return response.json()
# Execute
token = get_token()
result = call_fri(token, build_roster())
for schedule in result["processedSchedules"]:
print(f"Employee: {schedule['employeeName']}")
for score in schedule["fatigueScores"]:
print(f" Shift {score['shiftIndex']}: "
f"Fatigue={score['fatigueScore']:.1f}, "
f"Risk={score['riskIndex']:.1f}")JavaScript (Node.js)
const axios = require("axios");
const IDENTITY_URL = "https://frmsc-apim-euwest.azure-api.net/connect/token";
const API_BASE_URL = "https://frmsc-apim-euwest.azure-api.net";
const CLIENT_ID = "your_client_id";
const CLIENT_SECRET = "your_client_secret";
async function getToken() {
const params = new URLSearchParams({
grant_type: "client_credentials",
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
});
const response = await axios.post(IDENTITY_URL, params.toString(), {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
});
return response.data.access_token;
}
function buildRoster() {
return [
"J. Williams,03/06/2026,22:00,04/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,04/06/2026,22:00,05/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,05/06/2026,22:00,06/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,06/06/2026,22:00,07/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,07/06/2026,22:00,08/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,08/06/2026,22:00,09/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,09/06/2026,22:00,10/06/2026,06:00,3,1,60,1,360,0,45",
].join("\r\n");
}
async function callFRI() {
const token = await getToken();
const response = await axios.post(
`${API_BASE_URL}/api/RiskIndexProcessor/ProcessFatigueRisk`,
{ RosterData: buildRoster(), DateFormat: "dmy" },
{ headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
}},
);
return response.data;
}
callFRI().then((result) => {
result.processedSchedules.forEach((schedule) => {
console.log(`Employee: ${schedule.employeeName}`);
schedule.fatigueScores.forEach((score) => {
console.log(` Shift ${score.shiftIndex}: ` +
`Fatigue=${score.fatigueScore.toFixed(1)}, ` +
`Risk=${score.riskIndex.toFixed(1)}`);
});
});
});C# (.NET)
using System.Net.Http;
using System.Text;
using System.Text.Json;
const string IDENTITY_URL = "https://frmsc-apim-euwest.azure-api.net/connect/token";
const string API_BASE_URL = "https://frmsc-apim-euwest.azure-api.net";
const string CLIENT_ID = "your_client_id";
const string CLIENT_SECRET = "your_client_secret";
using var httpClient = new HttpClient();
// Step 1: Obtain token
var tokenRequest = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("grant_type", "client_credentials"),
new KeyValuePair<string, string>("client_id", CLIENT_ID),
new KeyValuePair<string, string>("client_secret", CLIENT_SECRET),
});
var tokenResponse = await httpClient.PostAsync(IDENTITY_URL, tokenRequest);
tokenResponse.EnsureSuccessStatusCode();
var tokenData = JsonSerializer.Deserialize<JsonElement>(
await tokenResponse.Content.ReadAsStringAsync());
var accessToken = tokenData.GetProperty("access_token").GetString();
// Step 2: Build roster
var rosterCsv = string.Join("\r\n", new[] {
"J. Williams,03/06/2026,22:00,04/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,04/06/2026,22:00,05/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,05/06/2026,22:00,06/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,06/06/2026,22:00,07/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,07/06/2026,22:00,08/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,08/06/2026,22:00,09/06/2026,06:00,3,1,60,1,360,0,45",
"J. Williams,09/06/2026,22:00,10/06/2026,06:00,3,1,60,1,360,0,45",
});
// Step 3: Call FRI+ API
httpClient.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
var requestBody = JsonSerializer.Serialize(new {
RosterData = rosterCsv,
DateFormat = "dmy",
});
var apiResponse = await httpClient.PostAsync(
$"{API_BASE_URL}/api/RiskIndexProcessor/ProcessFatigueRisk",
new StringContent(requestBody, Encoding.UTF8, "application/json"));
apiResponse.EnsureSuccessStatusCode();
var result = await apiResponse.Content.ReadAsStringAsync();
Console.WriteLine(result);cURL
# Step 1: Obtain token
TOKEN=$(curl -s -X POST \
"https://frmsc-apim-euwest.azure-api.net/connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
| jq -r '.access_token')
# Step 2: Call FRI+ API
curl -X POST \
"https://frmsc-apim-euwest.azure-api.net/api/RiskIndexProcessor/ProcessFatigueRisk" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"RosterData": "J. Williams,03/06/2026,22:00,04/06/2026,06:00,3,1,60,1,360,0,45\r\nJ. Williams,04/06/2026,22:00,05/06/2026,06:00,3,1,60,1,360,0,45",
"DateFormat": "dmy"
}'
Comments
0 comments
Please sign in to leave a comment.