Business Unit
Estimated reading: 3 minutes
Description :
Use this API to get Business Unit from anywhere (Web Browser, Native application in Android, iOS).
URL :
http:///custom_api/export_capex_details/business_units
Method : GET
Data Parameters | Required | Value |
---|---|---|
json or form-data | Yes | |
data_from_timestamp | No | |
URL Data Parameters | No | |
data_from_timestamp | Yes | 1663999021 |
current_page | Yes | 1 |
Example | Yes | ?data_from_timestamp=1663999021¤t_page=1 |
Header Parameters:
Authorization :
Bearer <Token>
Success Response :
Code : 200
Content :
{
"code": 200,
"message": "success",
"data": {
"number_of_results": "489",
"number_of_pages": 25,
"results_per_page": 20,
"current_page": "1",
"entity_name": "business_units",
"resultset": [
{
"id": "20317",
"name": "MyCompany / MYCOMPANY2",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20324",
"name": "MyCompany / MYCOMPANY3",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20325",
"name": "MyCompany / Central",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20326",
"name": "MyCompany / Latin America",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20327",
"name": "MyCompany / Ventures",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20648",
"name": "MyCompany / APAC",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "20752",
"name": "MyCompany / Asia",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "21645",
"name": "MyCompany / MyCompany Next",
"parent": "0",
"business_unit_code": null,
"type": "Division"
},
{
"id": "16758",
"name": "MyCompany / MYCOMPANY2 / United States",
"parent": "20317",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "16759",
"name": "MyCompany / MYCOMPANY2 / Canada",
"parent": "20317",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20330",
"name": "MyCompany / MYCOMPANY3 / Benelux",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20336",
"name": "MyCompany / MYCOMPANY3 / France",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20344",
"name": "MyCompany / MYCOMPANY3 / Eastern Europe",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20361",
"name": "MyCompany / MYCOMPANY3 / Germany & Switzerland",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20371",
"name": "MyCompany / MYCOMPANY3 / India",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20374",
"name": "MyCompany / MYCOMPANY3 / Italy",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20380",
"name": "MyCompany / MYCOMPANY3 / Iberia",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20384",
"name": "MyCompany / MYCOMPANY3 / United Kingdom",
"parent": "20324",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20389",
"name": "MyCompany / Central / Holding",
"parent": "20325",
"business_unit_code": null,
"type": "Sub Division"
},
{
"id": "20417",
"name": "MyCompany / Central / Germany & Switzerland",
"parent": "20325",
"business_unit_code": null,
"type": "Sub Division"
}
]
}
}
Error Response :
- Code: 401 BAD REQUEST
Content :
{
"code": 401,
"message": "fail",
"data": {
"error": "Invalid API Token"
}
}
Note :
Success response may change in future if required.
PHP Code :
/custom_api/export_capex_details/business_units?data_from_timestamp=1663999021¤t_page=1";
$headers = ['Authorization: Bearer '];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
$data = json_decode($response);
if ($data->code === 200) {
echo 'Success: ' . $data->message;
// Handle the success response data
} else {
// Handle the error response
}
}
curl_close($ch);
?>
JavaScript Code (using Fetch) :
var url = "http:///custom_api/export_capex_details/business_units?data_from_timestamp=1663999021¤t_page=1";
fetch(url, {
method: 'GET',
headers: {
'Authorization': 'Bearer ',
}
})
.then(response => response.json())
.then(data => {
if (data.code === 200) {
console.log('Success:', data.message);
// Handle the success response data
} else {
// Handle the error response
}
})
.catch(error => console.error('An error occurred:', error));
curl Cammand :
curl -X GET "http:///custom_api/export_capex_details/business_units?data_from_timestamp=1663999021¤t_page=1" \
-H "Authorization: Bearer "
These examples demonstrate how to make a GET request to the “Export Users” endpoint, using the authorization token and including the optional URL data parameters data_from_timestamp and current_page. Make sure to replace <server-ip-address> and <Token> with your actual server IP address and authorization token, respectively.