This API allows you to retrieve Cost Types from various platforms such as web browsers, native applications in Android, and iOS.
URL:
http://<server-ip-address>/custom_api/cost_type
Method: GET
| URL Parameters | Required |
|---|---|
| format=json (In future, Maybe change to default) | Yes |
| Optional | No |
Form Data Parameters:
None
Header Parameters:
Authorization:
Bearer <Token> (Replace <Token> with the actual access token)
Success Response:
Code: 200
Content:
{
"code": 200,
"message": "success",
"data": {
"7": "Engineering",
"9": "Shipping",
"10": "Contingency",
"11": "Equipment & Material",
"12": "Equipment Production",
"108": "IT Specialist",
"109": "Professional Services",
"110": "Office Equipment",
"158": "Contingency All",
"300": "Editable Field",
"302": "new"
}
}
Error Response:
Code: 401 BAD REQUEST
Content:
{
"code": 401,
"message": "fail",
"data": {
"error": "Invalid API Token"
}
}
Notes: The structure of the success response may change in the future if required.
Code Examples:
cURL Example:
curl -X GET "http://<server-ip-address>/custom_api/cost_type?format=json" -H "Authorization: Bearer <Token>"
PHP Example:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://<server-ip-address>/custom_api/cost_type?format=json',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer <Token>'
)
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
JavaScript Example (using Fetch API):
const url = 'http://<server-ip-address>/custom_api/cost_type?format=json';
const token = '<Token>';
fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));