1. Minimal API Test
Problem
How can I make my first API call test with Mobility Work?
Solution
- Obtain an API Key from Mobility Work
- Please contact your support team to get your API Key.
- Use the
Retrieve Network Settings
API to perform a test.
For integrators, the Retrieve Network Settings
API is ideal for end-to-end testing without any business constraints, because you don’t need to know any (business) information to test it.
It acts like an “echo” API:
- You simply call the API using your API Key.
- The GET request returns general information about the customer.
{
"networkId": "8b2b640a-ef8a-4dc6-83e3-fbcdfc568f7c",
"legacyNetworkId": 533,
"timezone": "Europe/Paris",
"currency": "EUR",
"name": "Example Factory"
}
How to?
Postman exemple
We provide ressource to use directly our APIs with Postman.
Go to this page to get more information how to use pre-build PostMan collections.
Step 0 : Download PostMan Collection
Step 1 : change the API Key
- Set your API Key on the collection
Step 2 : test
- Select
Retrieve network settings
request - Call API (send button)
- It's must work
PHP exemple
retrieve-network-settings.php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.mobility-work.com/partners/v1/network/settings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Api-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
// 2) Reformater en 'pretty print'
$json_obj = json_decode($response, true);
echo json_encode($json_obj, JSON_PRETTY_PRINT);
}
Result
HTTP 200
{
"networkId": "8b2b640a-ef8a-4dc6-83e3-fbcdfc568f7c",
"legacyNetworkId": 533,
"timezone": "Europe/Paris",
"currency": "EUR",
"name": "Example Factory"
}
Python exemple
retrieve-network-settings.py
import http.client
import json
conn = http.client.HTTPSConnection("api.mobility-work.com")
payload = ''
headers = {
'Accept': 'application/json',
'Api-Key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
conn.request("GET", "/partners/v1/network/settings", payload, headers)
res = conn.getresponse()
data = res.read()
json_obj = json.loads(data)
# 2) Reformater en 'pretty print'
pretty_str = json.dumps(json_obj, indent=4)
print(pretty_str)
Result
HTTP 200
{
"networkId": "8b2b640a-ef8a-4dc6-83e3-fbcdfc568f7c",
"legacyNetworkId": 533,
"timezone": "Europe/Paris",
"currency": "EUR",
"name": "Example Factory"
}
Curl exemple
Curl Exemple
curl -X GET "https://api.mobility-work.com/partners/v1/network/settings" \
-H "Accept: application/json" \
-H "Api-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | jq
Result
HTTP 200
{
"networkId": "8b2b640a-ef8a-4dc6-83e3-fbcdfc568f7c",
"legacyNetworkId": 533,
"timezone": "Europe/Paris",
"currency": "EUR",
"name": "Example Factory"
}
Test fails
Bad API Key return
HTTP 401
{
"message": "Invalid Api Key."
}
Your trial period has expired
HTTP 402
{
"message":"Your trial period has expired"
}
Other problems
You may encounter various types of security restrictions:
- IP restrictions: Your IT department may block certain IP ranges or allow access only from whitelisted IPs.
- Port filtering: Some ports required for API communication (such as 443 for HTTPS) may be closed.
- Deep Packet Inspection (DPI): Non-compliant or suspicious traffic may be blocked, even if it's using authorized ports.
- DNS filtering: The API domain name may be blocked or redirected to a warning or ban page.
- Blocking outgoing traffic to certain countries: If the API is hosted in a specific region, access to it could be blocked.
- Working hours restrictions: Access to certain services might be limited to specific times of the day.
- Intrusion Prevention Systems (IPS): These systems can block traffic that is deemed suspicious or abnormal.
- Bandwidth or traffic restrictions: If the system detects excessive usage, the connection may be throttled or blocked.
- …
How to test if your IT is blocking our APIs?
- Test with and without your corporate firewall.
- Try using another internet connection (e.g., mobile hotspot, home network).
- Do not use methods that are not compatible with your organization's security policies.
Next step
Congratulations! Your API test is successful (API Key is valid, no security issues, etc.). You are now ready to make your first valuable API integration.
You can try creating a task in Mobility Work using the document Your First API - Creating a Task: it explains step-by-step how to create your first Mobility Work API from scratch.
References
- API
- Documentation