Request cURL JavaScript Python Java PHP C#
curl -X POST 'https://bemap.benomad.com/bgis/service/traffic/1.0' \
-u 'YOUR_ACCOUNT:YOUR_API_KEY' \
--fail-with-body \
-H 'Content-Type: application/json' \
-d '{
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": [
"POLYLINE"
]
}'const response = await fetch('https://bemap.benomad.com/bgis/service/traffic/1.0', {
method: 'POST',
headers: {
Authorization: 'Basic ' + btoa('YOUR_ACCOUNT:YOUR_API_KEY'),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": [
"POLYLINE"
]
}),
redirect: 'manual', // a missing credential answers 302: never follow it
});
if (response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400)) throw new Error('BeMap redirected to its login page: no credentials reached it');
if (!response.ok) throw new Error(`BeMap answered ${response.status}: ${await response.text()}`);
const data = await response.json();import requests
response = requests.post(
"https://bemap.benomad.com/bgis/service/traffic/1.0",
auth=("YOUR_ACCOUNT", "YOUR_API_KEY"),
json={
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42,
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": ["POLYLINE"],
},
allow_redirects=False, # a missing credential answers 302: never follow it
)
if response.is_redirect:
raise RuntimeError("BeMap redirected to its login page: no credentials reached it")
if response.status_code != 200:
raise RuntimeError(f"BeMap answered {response.status_code}: {response.text}")
data = response.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
String auth = Base64.getEncoder().encodeToString("YOUR_ACCOUNT:YOUR_API_KEY".getBytes(StandardCharsets.UTF_8));
String body = """
{
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": [
"POLYLINE"
]
}
""";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://bemap.benomad.com/bgis/service/traffic/1.0"))
.header("Authorization", "Basic " + auth)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
// HttpClient never follows redirects by default: a 302 means a missing credential.
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() / 100 == 3) throw new IllegalStateException("BeMap redirected to its login page: no credentials reached it");
if (response.statusCode() != 200) throw new IllegalStateException("BeMap answered " + response.statusCode() + ": " + response.body());
String json = response.body();<?php
$body = <<<'JSON'
{
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": [
"POLYLINE"
]
}
JSON;
$ch = curl_init('https://bemap.benomad.com/bgis/service/traffic/1.0');
curl_setopt_array($ch, [
CURLOPT_USERPWD => 'YOUR_ACCOUNT:YOUR_API_KEY',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => false, // a missing credential answers 302: never follow it
]);
$response = curl_exec($ch);
if ($response === false) throw new RuntimeException(curl_error($ch));
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 300 && $status < 400) throw new RuntimeException('BeMap redirected to its login page: no credentials reached it');
if ($status !== 200) throw new RuntimeException("BeMap answered $status: $response");
$data = json_decode($response, true);using System.Net;
using System.Net.Http.Headers;
using System.Text;
// AllowAutoRedirect = false: a missing credential answers 302, never follow it.
var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false });
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes("YOUR_ACCOUNT:YOUR_API_KEY"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", token);
var body = """
{
"boundingBox": {
"minLat": 48.8,
"minLon": 2.25,
"maxLat": 48.92,
"maxLon": 2.42
},
"countryCode": "FRA",
"outputLanguage": "fr",
"options": [
"POLYLINE"
]
}
""";
var response = await client.SendAsync(new HttpRequestMessage(HttpMethod.Post, "https://bemap.benomad.com/bgis/service/traffic/1.0")
{
Content = new StringContent(body, Encoding.UTF8, "application/json"),
});
if ((int)response.StatusCode / 100 == 3) throw new HttpRequestException("BeMap redirected to its login page: no credentials reached it");
if (response.StatusCode != HttpStatusCode.OK) throw new HttpRequestException($"BeMap answered {(int)response.StatusCode}: {await response.Content.ReadAsStringAsync()}");
var json = await response.Content.ReadAsStringAsync();{
"countryInitialized": true,
"trafficResponseElements": [
{
"trafficItem": {
"info": {
"countryCode": "FRA",
"copyright": "HERE",
"releaseDate": 1790944338000,
"lastUpdateDate": 1790944356323
},
"elementId": "520397642",
"reverseDirection": false,
"boundingBox": {
"minLon": 2.36032,
"minLat": 48.86191,
"maxLon": 2.36461,
"maxLat": 48.86426
},
"jamFactor": 51.360798,
"reason": "NA",
"reasonCoordinate": {
"lon": 2.36032,
"lat": 48.86426
},
"polyline": [
{
"lon": 2.36032,
"lat": 48.86426
},
{
"lon": 2.36052,
"lat": 48.86412
}
],
"segmentInfos": [
{
"id": "4385172450468",
"reverseDirection": true
},
{
"id": "4385172503580",
"reverseDirection": false
}
],
"tmcInternalId": 520397642,
"alertcEbuCountryCode": "F",
"alertcTableId": 32,
"alertcLocationId": 41802,
"alertcExtend": 0,
"alertcCode": 115
}
},
{
"trafficItem": {
"info": {
"countryCode": "FRA",
"copyright": "HERE",
"releaseDate": 1790944338000,
"lastUpdateDate": 1790944356323
},
"elementId": "520397639",
"reverseDirection": false,
"boundingBox": {
"minLon": 2.36664,
"minLat": 48.8558,
"maxLon": 2.36849,
"maxLat": 48.85605
},
"jamFactor": 83.087,
"reason": "NA",
"reasonCoordinate": {
"lon": 2.36732,
"lat": 48.85594
},
"polyline": [
{
"lon": 2.36732,
"lat": 48.85594
},
{
"lon": 2.36818,
"lat": 48.8558
}
],
"segmentInfos": [
{
"id": "4385172502648",
"reverseDirection": false
},
{
"id": "4385172502799",
"reverseDirection": false
}
],
"tmcInternalId": 520397639,
"alertcEbuCountryCode": "F",
"alertcTableId": 32,
"alertcLocationId": 41799,
"alertcExtend": 0,
"alertcCode": 108
}
}
]
}Captured from production. Long arrays and strings are shortened.
Build with AI
Write the code that calls the BeMap API operation "Traffic": POST https://bemap.benomad.com/bgis/service/traffic/1.0
- Authenticate with HTTP Basic: the BeMap account as the user name, the API key as the password. Do not follow redirects: a 302 means the credentials were not sent.
- Send JSON (Content-Type: application/json) of type `TrafficRequest`.
- Use only the fields the reference lists: BeMap ignores an unknown field name without an error, so a misspelt field configures nothing.
- A 400 with "Access Denied" means the account lacks this service; a 401, a wrong account or key.
Reference, with every field and what each value means: https://benomad.com/dev/doc/bemap-api/api/map-context/traffic.md Copy prompt Open in Claude Open in ChatGPT With the BeMap MCP server , your assistant also checks each request against the specification before sending it.