1. User management

Documentation for Web developers

Description

Use this API to login a user from anywhere, including web browsers, native applications on Android and iOS.

Base URL:

The following API Resources use http://<server-ip-address> as the base URL:

1.1 Login User

Login User

Use this API to login a user from anywhere, including web browsers, native applications on Android and iOS.

API URL:

				
					http://<server-ip-address>/custom_api/login
				
			

Method: POST

Form Data Parameters:
				
					{
  "username": "Your_Username",
  "password": "Your_Password",
  "parent_id": 50511
}

				
			
URL Parameters Required
format = json (In future, Maybe change to default)
Yes
parent_id
No
Success Response
				
					{
  "code": 200,
  "message": "success",
  "data": {
    "token": "b9e223b8c1d2917a28f6cf774c3ef720356cef7a6f37189db66ef41e3d468587e11b157e872c99d82935e5292f2f31944e48017a930e9a128c494e63"
  }
}

				
			
Error Response
				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid email or password"
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[email]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This field is missing."
    ],
    "[email]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This field is missing."
    ]
  }
}

				
			

OR

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "[password]": [
      "This value should not be blank."
    ]
  }
}


				
			

Code example

Here’s an example code snippet in Python using the requests library to make the API call to the “Login User” endpoint:

Python Example:

Here’s a corresponding example using cURL command in the command line:

cURL Example:

				
					import requests

url = 'http://<server-ip-address>/custom_api/login'
data = {
    'username': 'Your_Username',
    'password': 'Your_Password',
    'parent_id': 50511
}

response = requests.post(url, json=data)
if response.status_code == 200:
    json_response = response.json()
    token = json_response['data']['token']
    print('Login successful. Token:', token)
else:
    print('Login failed:', response.json()['data']['error'])

				
			
				
					curl -X POST -H "Content-Type: application/json" -d '{
    "username": "Your_Username",
    "password": "Your_Password",
    "parent_id": 50511
}' http://<server-ip-address>/custom_api/login

				
			

2. Request Type Management

2.1 Capex Request Type

Description:

This API allows you to retrieve Capex Request Types from various platforms such as web browsers, native applications in Android, and iOS.

API URL:

				
					http://<server-ip-addres>/custom_api/capex_type
				
			
Method: GET
URL Parameters:
URL Parametersr Required
format=json (In future, Maybe change to default)
Yes
Optional
None

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": {
    "standalone": "Standalone Capex",
    "project": "Project",
    "envelope": "Envelope",
    "other": "Other",
    "Test Satish": "Test Satish"
  }
}

				
			
Error Response:

Code: 401 BAD REQUEST

Content:

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			
Notes:

Code Examples:

cURL Example:

				
					curl -X GET "http://<server-ip-address>/custom_api/capex_type?format=json" -H "
				
			
Authorization:
				
					Bearer <Token>"
				
			

PHP Code:

				
					<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://<server-ip-address>/custom_api/capex_type?format=json',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer <Token>'
  )
));

$response = curl_exec($curl);
curl_close($curl);

echo $response;
?>

				
			
JavaScript code:
				
					const url = 'http://<server-ip-address>/custom_api/capex_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));

				
			
Note:

3. Business Unit Management

3.1 Business Unit

Description:

This API allows you to retrieve Business Units from various platforms such as web browsers, native applications in Android, and iOS.

URL:

				
					http://<server-ip-address>/custom_api/business_unit
				
			
Method: GET
URL Parameters Required
format=json (In future, Maybe change to default)
Yes
Optional
No

Form Data Parameters:

No

Header Parameters:

Authorization:

				
					Bearer <Token> (Replace <Token> with the actual access token)
				
			
Success Response:

Code: 200

Content:

				
					{
  "code": 200,
  "message": "success",
  "data": [
    {
      "id": 9096,
      "name": " / Aurora"
    },
    {
      "id": 9099,
      "name": " / Aurora / Group 1"
    },
    {
      "id": 9102,
      "name": " / Aurora / Group 1 / Building A New"
    }
  ]
}

				
			
Error Response:

Code: 401 BAD REQUEST

Content:

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

Notes

Code Examples:

cURL Example:

				
					curl -X GET "http://<server-ip-address>/custom_api/business_unit?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/business_unit?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/business_unit?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));

				
			
Note:

4. Cost Type Management

4.1 Cost Type Management

Description:

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:

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));

				
			
Note:

5. Permitted Currency Management

5.1 Permitted Currency Management

Description:

This API allows you to retrieve Permitted Currencies from various platforms such as web browsers, native applications in Android, and iOS.

URL:

				
					http://<server-ip-address>/custom_api/permitted_currency
				
			
Method: GET
URL Parameters Required
format=json (In future, Maybe change to default)
Yes
Optional
No

Form Data Parameters:

No

Header Parameters:

Authorization:

				
					Bearer <Token> (Replace <Token> with the actual access token)
				
			
Success Response:

Code: 200

Content:

				
					{
  "code": 200,
  "message": "success",
  "data": [
    "ARS",
    "AUD",
    "BRL",
    "CAD",
    "EUR",
    "JOD",
    "USD"
  ]
}

				
			

Error Response:

Code: 401 BAD REQUEST

Content:

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

Notes:

Code Examples:

cURL Example:

				
					curl -X GET "http://<server-ip-address>/custom_api/permitted_currency?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/permitted_currency?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/permitted_currency?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));

				
			
Note:

6. PO Fields

6.1 PO Fields

Description:

Use this API to get PO Fields from anywhere (Web Browser, Native application in android, iOS).

URL:

				
					http://<server-ip-address>/custom_api/tracking_page_fields
				
			
Method:GET
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

Key Value
Page_name
Capex_track_purchase_orders

page_name: capex_track_purchase_orders

Header Parameters :

Authorization :

				
					Bearer <Token>
				
			
Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": [
    {
      "field": "business_unit_name",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "request_number",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "PO_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "description",
      "field_type": "text",
      "field_size": 100
    },
    {
      "field": "vendor_name",
      "field_type": "text",
      "field_size": 50
    },
    {
      "field": "vendor_number",
      "field_type": "text",
      "field_size": 50
    },
    {
      "field": "PO_amount",
      "field_type": "currency",
      "field_size": 24
    },
    {
      "field": "vendor_currency",
      "field_type": "currency_value",
      "field_size": null
    },
    {
      "field": "capex_to_vendor_currency_rate",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "committed",
      "field_type": "currency",
      "field_size": 24
    },
    {
      "field": "status",
      "field_type": "select",
      "field_size": 200
    },
    {
      "field": "expense_type",
      "field_type": "select",
      "field_size": 255
    }
  ]
}

				
			
Error Response:

Code: 401 BAD REQUEST

Content:

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[page_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes:

Sample Code :

JavaScript:

				
					// Using Fetch API
const apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields';
const token = '<Token>';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  // Process the data here
})
.catch(error => {
  // Handle error
});

				
			
PHP Example :
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields';
$token = '<Token>';

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
cURL Example :
cURL :
				
					curl --location --request GET 'http://<server-ip-address>/custom_api/tracking_page_fields' \
--header 'Authorization: Bearer <Token>'

				
			

In Postman, you can follow these steps to use the cURL command:

 

  1. Open Postman and create a new request.
  2. Choose the “GET” method.
  3. Enter the URL http://<server-ip-address>/custom_api/tracking_page_fields in the request URL field.
  4. Go to the “Headers” section and add a new header with the key “Authorization” and the value “Bearer <Token>” (replace <Token> with your actual API token).
  5. Click the “Send” button to execute the request.

This format should work correctly in Postman for making the cURL request to the API endpoint.

7. PO Line Items Fields

7.1 PO Line Items Fields

Description :

Use this API to get PO Line Items Fields from anywhere (Web Browser, Native application in android, iOS).

URL :

				
					http://<server-ip-address>/custom_api/tracking_page_fields
				
			
Method: GET
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

Key Value
page_name
capex_track_purchase_order_line_items

Header Parameters :

Authorization :

				
					Bearer <Token>
				
			

Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": [
    {
      "field": "business_unit_name",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "request_number",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "PO_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "general_cost_type_id",
      "field_type": "select",
      "field_size": 255
    },
    {
      "field": "line_item_description",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "asset",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "work_order",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "CER",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "quantity",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "quantity_received",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "unit_cost",
      "field_type": "currency",
      "field_size": 11
    },
    {
      "field": "PO_line_status",
      "field_type": "select",
      "field_size": 255
    },
    {
      "field": "deposit",
      "field_type": "text",
      "field_size": 45
    }
  ]
}

				
			
Error Response :

Code: 401 BAD REQUEST

Content :

				
					json{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[page_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes :

Sample Code :

JavaScript Example :

				
					const apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields';
const token = '<Token>';

fetch(apiUrl + '?format=json', {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  // Process the data here
})
.catch(error => {
  // Handle error
});

				
			
PHP Example:
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields';
$token = '<Token>';

$ch = curl_init($apiUrl . '?format=json');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
cURL :
cURL Example :
				
					curl --location --request GET 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json' \
--header 'Authorization: Bearer <Token>'

				
			

8. Track Invoice Fields

8.1 Track Invoice Fields

Description :

Use this API to get Track Invoice Fields from anywhere (Web Browser, Native application in android, iOS).

URL :

				
					http://<server-ip-address>/custom_api/tracking_page_fields

				
			
Method: GET
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

Key Value
page_name
capex_track_invoices

Header Parameters :

Authorization :

				
					Bearer <Token>
				
			

Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": [
    {
      "field": "business_unit_name",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "request_number",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "PO_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "invoice_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "amount_in_vendor_currency",
      "field_type": "currency",
      "field_size": 11
    },
    {
      "field": "vendor_currency",
      "field_type": "currency_value",
      "field_size": null
    },
    {
      "field": "asset",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "work_order",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "invoice_date",
      "field_type": "date",
      "field_size": null
    },
    {
      "field": "general_cost_type_id",
      "field_type": "select",
      "field_size": 255
    },
    {
      "field": "CER",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "quantity",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "quantity_received",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "unit_cost",
      "field_type": "currency",
      "field_size": 11
    },
    {
      "field": "rate",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "expense_type",
      "field_type": "select",
      "field_size": 255
    }
  ]
}

				
			
Error Response :

Code: 401 BAD REQUEST

Content :

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[page_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes :

Success response may change in the future if required.

More Explanation:

The API provides information about various Track Invoice Fields, including business unit name, request number, PO number, invoice number, amount in vendor currency, vendor currency, asset, work order, invoice date, general cost type ID, CER (Cost and Equipment Request), quantity, quantity received, unit cost, rate, and expense type. The data is returned in JSON format.

Instructions to Use:

To use the API, follow these steps:

Obtain a valid API token.

Make a GET request to the API URL

				
					http://<server-ip-address>/custom_api/tracking_page_fields?format=json
				
			

Add the Authorization header with the value Bearer <Token> to authenticate the request.

Include the form data parameter page_name with the value capex_track_invoices.

Sample Code :

JavaScript Example :

				
					const apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json';
const token = '<Token>';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  // Process the data here
})
.catch(error => {
  // Handle error
});
const apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json';
const token = '<Token>';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  // Process the data here
})
.catch(error => {
  // Handle error
});

				
			
PHP Example :
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json';
$token = '<Token>';

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
cURL :
cURL Example :
				
					curl --location --request GET 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json' \
--header 'Authorization: Bearer <Token>'

				
			

9. Track Reception Fields

9.1 Track Reception Fields

Description :

Use this API to get Track Reception Fields from anywhere (Web Browser, Native application in android, iOS).

URL :

				
					http://<server-ip-address>/custom_api/tracking_page_fields

				
			
Method: GET
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

page_name: capex_track_receptions

Header Parameters :

Key Value
Page_name:
capex_track_receptions

Authorization :

				
					Bearer <Token>
				
			

Success Response :

Code: 200

Content:

				
					{
  "code": 200,
  "message": "success",
  "data": [
    {
      "field": "business_unit_name",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "request_number",
      "field_type": "text",
      "field_size": null
    },
    {
      "field": "PO_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "reception_number",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "asset",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "work_order",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "general_cost_type_id",
      "field_type": "select",
      "field_size": 255
    },
    {
      "field": "CER",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "quantity",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "quantity_received",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "unit_cost",
      "field_type": "currency",
      "field_size": 11
    },
    {
      "field": "reception_date",
      "field_type": "date",
      "field_size": null
    },
    {
      "field": "receiver",
      "field_type": "text",
      "field_size": 255
    },
    {
      "field": "accepted",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "rejected",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "unit_cost_vendor_currency",
      "field_type": "currency",
      "field_size": 11
    },
    {
      "field": "vendor_currency",
      "field_type": "currency_value",
      "field_size": null
    },
    {
      "field": "rate",
      "field_type": "numeric",
      "field_size": 11
    },
    {
      "field": "expense_type",
      "field_type": "select",
      "field_size": 255
    }
  ]
}

				
			
Error Response

Code: 401 BAD REQUEST

Content :

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[page_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes :

Sample Code

Javascript Example :

				
					const apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json';
const token = '<Token>';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
})
.then(response => response.json())
.then(data => {
  // Process the data here
})
.catch(error => {
  // Handle error
});

				
			
PHP Example :
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json';
$token = '<Token>';

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
cURL :
cURL Example :
				
					curl --location --request GET 'http://<server-ip-address>/custom_api/tracking_page_fields?format=json' \
--header 'Authorization: Bearer <Token>'

				
			
Note :

10. Create PO

10.1 Create PO

Description :

Use this API to create a new Purchase Order (PO) with the provided details.

URL :

				
					 http://<server-ip-address>/custom_api/capex_track_purchase_order/create
				
			
Method: POST
URL Parameters Required
format=json (In the future, maybe change to default)
Yes

Form Data Parameters :

Key Value
business_unit_name:
Almiranta1 / Aurora
request_number
AU-2020-4133
PO_number:
1
vendor_name
sdfsddf
vendor_number:
sdfsdf
PO_amount
5.85555
vendor_currency
USD
capex_to_vendor_currency_rate
1
committed
858
expense_type
Capital Expenditures

Header Parameters :

Authorization :

				
					Bearer <Token>
				
			

Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": []
}

				
			

Error Response

Code: 401 BAD REQUEST

Content :

				
					json{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

OR

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[field_name]": [
      "This field is missing."
    ]
  }
}

				
			

Notes :

Explanation :

The API allows you to create a new Purchase Order (PO) by submitting the necessary details as form data parameters. These details include business unit name, request number, PO number, description, vendor name, vendor number, PO amount, vendor currency, conversion rate from capex to vendor currency, committed amount, status of the PO, and the expense type.

Sample Code :

JavaScript (Using Fetch API) :

				
					const apiUrl = 'http://<server-ip-address>/custom_api/capex_track_purchase_order/create';
const token = '<Token>';

const formData = new FormData();
formData.append('business_unit_name', 'Almiranta1 / Aurora');
formData.append('request_number', 'AU-2020-4133');
formData.append('PO_number', '1');
formData.append('description', 'sdfsdf');
formData.append('vendor_name', 'sdfsddf');
formData.append('vendor_number', 'sdfsdf');
formData.append('PO_amount', '5.85555');
formData.append('vendor_currency', 'USD');
formData.append('capex_to_vendor_currency_rate', '1');
formData.append('committed', '858');
formData.append('status', 'Open');
formData.append('expense_type', 'Capital Expenditures');

fetch(apiUrl + '?format=json', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`
  },
  body: formData
})
.then(response => response.json())
.then(data => {
  // Process the response data here
})
.catch(error => {
  // Handle error
});

				
			
PHP (Using cURL) :
				
					<?php
$apiUrl = 'http://<server-ip-address>/custom_api/capex_track_purchase_order/create';
$token = '<Token>';

$data = array(
  'business_unit_name' => 'Almiranta1 / Aurora',
  'request_number' => 'AU-2020-4133',
  'PO_number' => '1',
  'description' => 'sdfsdf',
  'vendor_name' => 'sdfsddf',
  'vendor_number' => 'sdfsdf',
  'PO_amount' => '5.85555',
  'vendor_currency' => 'USD',
  'capex_to_vendor_currency_rate' => '1',
  'committed' => '858',
  'status' => 'Open',
  'expense_type' => 'Capital Expenditures'
);

$ch = curl_init($apiUrl . '?format=json');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (!$response) {
  // Handle cURL error
}

$data = json_decode($response, true);

if (isset($data['code']) && $data['code'] === 200) {
  // Process the response data here
} else {
  // Handle API error
}

curl_close($ch);
?>

				
			
Note :

11. Create PO Line Items

11.1 Create PO Line Items

Description :

This API allows you to create PO (Purchase Order) line items. It can be used from various sources such as a web browser, native applications in Android, or iOS devices.

URL :

Endpoint:

				
					http://<server-ip-address>/custom_api/capex_track_purchase_order_line_item/create;
				
			
Method : Post
URL Parameters: Required:
format=json (In the future, this parameter might change to become the default format)
Yes

Form Data Parameters:

KeyDetailValue
business_unit_nameSpecify the business unit name.Almiranta1 / Aurora
request_numberThe request number associated with the purchase order AU-2020-4133
PO_numberThe purchase order number 1
general_cost_type_idID of the general cost type.7
line_item_descriptionDescription of the line item.
assetThe asset related to the line item.
work_orderWork order details.
CERCER (Cost Estimation Request) information.
quantityQuantity of items being ordered.10
quantity_receivedQuantity received for the ordered items. 895
unit_cost Unit cost of the items 9857
PO_line_statusStatus of the PO line.Open
depositDeposit details.

Header Parameters :

Authorization :

				
					Bearer <Token> (Include a valid access token to authorize the API request)

				
			
Success Response:

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": []
}

				
			

Error Responses:

Code: 401 BAD REQUEST

Content :

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

Code: 400

Content :

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[field_name]": [
      "This field is missing."
    ]
  }
}

				
			

Code: 400

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[PO_number]": "Multiple PO found!"
  }
}

				
			
Notes :

PHP Code :

				
					<?php
// API Endpoint URL
$url = 'http://<server-ip-address>/custom_api/capex_track_purchase_order_line_item/create';

// Form Data Parameters
$data = array(
    'business_unit_name' => 'Almiranta1', // Change this value accordingly
    'request_number' => 'AU-2020-4133', // Change this value accordingly
    'PO_number' => '1', // Change this value accordingly
    'general_cost_type_id' => '7', // Change this value accordingly
    'line_item_description' => 'Line Item Description', // Change this value accordingly
    'asset' => 'Asset', // Change this value accordingly
    'work_order' => 'Work Order', // Change this value accordingly
    'CER' => 'CER', // Change this value accordingly
    'quantity' => '10', // Change this value accordingly
    'quantity_received' => '895', // Change this value accordingly
    'unit_cost' => '9857', // Change this value accordingly
    'PO_line_status' => 'Open', // Change this value accordingly
    'deposit' => 'Deposit', // Change this value accordingly
);

// HTTP Header with Authorization Bearer Token
$headers = array(
    'Authorization: Bearer <Token>', // Replace <Token> with your actual access token
);

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute cURL session and capture the response
$response = curl_exec($ch);

// Close cURL session
curl_close($ch);

// Process the response
if ($response === false) {
    echo 'Error: ' . curl_error($ch);
} else {
    // Decode the JSON response
    $responseData = json_decode($response, true);

    // Check the response code for success/failure
    if ($responseData['code'] === 200) {
        // Success
        echo 'Successfully created PO Line Item!';
    } else {
        // Failure
        echo 'Error: ' . $responseData['message'];
    }
}
?>

				
			
JavaScript Code (using fetch):
				
					// API Endpoint URL
const url = 'http://<server-ip-address>/custom_api/capex_track_purchase_order_line_item/create';

// Form Data Parameters
const data = new URLSearchParams();
data.append('business_unit_name', 'Almiranta1'); // Change this value accordingly
data.append('request_number', 'AU-2020-4133'); // Change this value accordingly
data.append('PO_number', '1'); // Change this value accordingly
data.append('general_cost_type_id', '7'); // Change this value accordingly
data.append('line_item_description', 'Line Item Description'); // Change this value accordingly
data.append('asset', 'Asset'); // Change this value accordingly
data.append('work_order', 'Work Order'); // Change this value accordingly
data.append('CER', 'CER'); // Change this value accordingly
data.append('quantity', '10'); // Change this value accordingly
data.append('quantity_received', '895'); // Change this value accordingly
data.append('unit_cost', '9857'); // Change this value accordingly
data.append('PO_line_status', 'Open'); // Change this value accordingly
data.append('deposit', 'Deposit'); // Change this value accordingly

// Fetch POST request
fetch(url, {
    method: 'POST',
    body: data,
    headers: {
        'Authorization': 'Bearer <Token>', // Replace <Token> with your actual access token
    },
})
.then(response => response.json())
.then(responseData => {
    // Check the response code for success/failure
    if (responseData.code === 200) {
        // Success
        console.log('Successfully created PO Line Item!');
    } else {
        // Failure
        console.error('Error: ' + responseData.message);
    }
})
.catch(error => console.error('Error: ', error));
				
			
Note :

Here’s an example of how you can use cURL to make a POST request to the API endpoint:

Explanation :

curl -X POST :

				
					'http://<server-ip-address>/custom_api/capex_track_purchase_order_line_item/create' \
     -H 'Authorization: Bearer <Token>' \
     -H 'Content-Type: application/x-www-form-urlencoded' \
     -d 'business_unit_name=Almiranta1' \
     -d 'request_number=AU-2020-4133' \
     -d 'PO_number=1' \
     -d 'general_cost_type_id=7' \
     -d 'line_item_description=Line Item Description' \
     -d 'asset=Asset' \
     -d 'work_order=Work Order' \
     -d 'CER=CER' \
     -d 'quantity=10' \
     -d 'quantity_received=895' \
     -d 'unit_cost=9857' \
     -d 'PO_line_status=Open' \
     -d 'deposit=Deposit'

				
			
  • curl: The command-line tool to perform HTTP requests.
  • -X POST: Specifies that we are making a POST request.
  • -H ‘Authorization: Bearer <Token>’: Sets the Authorization header with the Bearer Token. Replace <Token> with your actual access token.
  • -H ‘Content-Type: application/x-www-form-urlencoded’: Specifies the content type of the data being sent as URL-encoded form data.
  • -d ‘parameter=value’: Adds the form data parameters as key-value pairs in the request body.
  • Replace <server-ip-address> and <Token> in the URL and Authorization header, respectively, with the actual server IP address and valid access token.

12. Create Invoice Line Items

12.1 Create Invoice Line Items

Description :

This API allows you to create invoice line items. It can be used from various sources such as a web browser, native applications in Android, or iOS devices.

URL :

Endpoint :

				
					http://<server-ip-address>/custom_api/capex_track_invoice_line_item/create

				
			
Method : POST
URL Parameters Required
json (In the future, this parameter might change to become the default format)
Yes

Form Data Parameters:

KeyDetailValue
business_unit_name:Specify the business unit name Almiranta1 / Aurora
request_numberThe request number associated with the invoice.AU-2020-4133
PO_numberThe associated purchase order number1
invoice_numberThe invoice number .1
amount_in_vendor_currencyThe amount in the vendor's currency.58
vendor_currencyThe currency of the vendor USD
assetThe asset related to the invoice line item.
work_orderWork order details.
invoice_dateThe date of the invoice . 2020-02-02
general_cost_type_idID of the general cost type 7
CERCER (Cost Estimation Request) information.
quantityQuantity of items being invoiced10
quantity_receivedQuantity received for the invoiced items 895
unit_cost:Unit cost of the items 9857
rateThe rate associated with the invoice. 2
expense_typeType of expense, such as "Capital Expenditures".

Header Parameters :

Authorization :

				
					Bearer <Token> (Include a valid access token to authorize the API request)
				
			
Success Response:

Code : 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": []
}

				
			

Error Response :

Code: 401 BAD REQUEST

Content :

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

Code: 400

Content :

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[field_name]": [
      "This field is missing."
    ]
  }
}

				
			

Code: 400

Content :

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[PO_number]": "Multiple PO found!"
  }
}

				
			
Note :

Curl Command :

Here’s an example of how you can use cURL to make a POST request to the API endpoint:

curl -X POST :

				
					'http://<server-ip-address>/custom_api/capex_track_invoice_line_item/create' \

     -H 'Authorization: Bearer <Token>' \

     -H 'Content-Type: application/x-www-form-urlencoded' \

     -d 'business_unit_name=Almiranta1' \

     -d 'request_number=AU-2020-4133' \

     -d 'PO_number=1' \

     -d 'invoice_number=I1' \

     -d 'amount_in_vendor_currency=58' \

     -d 'vendor_currency=USD' \

     -d 'asset=Asset' \

     -d 'work_order=Work Order' \

     -d 'invoice_date=2020-02-02' \

     -d 'general_cost_type_id=7' \

     -d 'CER=CER' \

     -d 'quantity=10' \

     -d 'quantity_received=895' \

     -d 'unit_cost=9857' \

     -d 'rate=2' \

     -d 'expense_type=Capital Expenditures'
				
			
Note :

13. Create Reception Line Items

13.1 Create Reception Line Items

Description :

This API allows you to create reception line items. It can be used from various sources such as a web browser, native applications in Android, or iOS devices.

URL :

Endpoint :

				
					http://<server-ip-address>/custom_api/capex_track_reception_line_item/create
				
			
Method : POST
URL Parameters Required
format=json (In the future, this parameter might change to become the default format)
Yes

Form Data Parameters :

KeyDetrailsValue
business_unit_nameSpecify the business unit name Almiranta1 / Aurora
request_numberThe request number associated with the reception. AU-2020-4133
PO_number:The associated purchase order number 1
reception_numberThe reception number R1
vendor_currencyThe currency of the vendor. USD
assetThe asset related to the reception line item.
work_orderWork order details
general_cost_type_idID of the general cost type7
CER:CER (Cost Estimation Request) information.
quantity10Quantity of items being received
quantity_receivedQuantity received for the items 895
unit_costUnit cost of the items 9857
reception_dateThe date of the reception 2020-02-02
receiverThe receiver's name or identifier Receiver 1
acceptedQuantity of items accepted from the reception 10
rejectedQuantity of items rejected from the reception 2
unit_cost_vendor_currencyUnit cost of the items in the vendor's currency58
rateThe rate associated with the reception2
expense_type Type of expense, such as "Capital Expenditures".

Header Parameters :

Authorization :

				
					Bearer <Token> (Include a valid access token to authorize the API request)
				
			
Success Response :

Code: 200

Content :

				
					{
  "code": 200,
  "message": "success",
  "data": []
}

				
			

Error Responses :

Code: 401 BAD REQUEST

Content :

				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			

Code: 400

Content :

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[field_name]": [
      "This field is missing."
    ]
  }
}


				
			

Code: 400

Content :

				
					{
  "code": 400,
  "message": "fail",
  "data": {
    "[PO_number]": "Multiple PO found!"
  }
}

				
			
Curl Command :

Here’s an example of how you can use cURL to make a POST request to the API endpoint:

curl -X POST :

				
					'http://<server-ip-address>/custom_api/capex_track_reception_line_item/create' \

     -H 'Authorization: Bearer <Token>' \

     -H 'Content-Type: application/x-www-form-urlencoded' \

     -d 'business_unit_name=Almiranta1' \

     -d 'request_number=AU-2020-4133' \

     -d 'PO_number=1' \

     -d 'reception_number=R1' \

     -d 'vendor_currency=USD' \

     -d 'asset=Asset' \

     -d 'work_order=Work Order' \

     -d 'general_cost_type_id=7' \

     -d 'CER=CER' \

     -d 'quantity=10' \

     -d 'quantity_received=895' \

     -d 'unit_cost=9857' \

     -d 'reception_date=2020-02-02' \

     -d 'receiver=Receiver 1' \

     -d 'accepted=10' \

     -d 'rejected=2' \

     -d 'unit_cost_vendor_currency=58' \

     -d 'rate=2' \

     -d 'expense_type=Capital Expenditures'
				
			
Note :

14. DISBURSEMENT TIMELINE

  •  1.1 Description
  • 1.2 URL
  • 1.3 Method
  • 1.4 URL Parameters
  • 1.5 URL Data Parameters
  • 1.6 Header Parameters
  • 1.7 Success Response
  • 1.8 Error Response
  • 1.9 Notes

Description :

This API is designed to fetch the Capex Request DISBURSEMENT TIMELINE and can be accessed through web browsers, native applications on Android, and iOS.

URL :

				
					http://<server-ip-address>/custom_api/export_capex_details/capex_disbursement_spend_timeline
				
			
Method : GET
URL ParametersRequiredValue
Content Type FormatYesjson or form-data
data_from_timestampYesCapex_id
URL Data ParametersNo
data_from_timestampYes1
capex_idYes1
current_pageYes1
ExampleYes?capex_id=1&data_from_timestamp=1¤t_page=1

Header Parameters:

Authorization :

Bearer <Token>

Success Response :

Code : 200

Content :

				
					{
    "code": 200,
    "message": "success",
    "data": {
        "number_of_results": "4897",
        "number_of_pages": 245,
        "results_per_page": 20,
        "current_page": "1",
        "entity_name": "capex_request_disbursement_spend_timeline",
        "resultset": [
            {
                "timeline_type": {
                    "label": "Monthly",
                    "value": "Monthly"
                },
                "year": {
                    "label": "Year",
                    "value": "2021"
                },
                "amount": {
                    "label": "Amount",
                    "value": "54516.00"
                },
                "month_or_qtr": {
                    "label": "Month or Quarter",
                    "value": "08"
                },
                "capex_id": {
                    "label": "Capex Id",
                    "value": "11252"
                },
                "id": {
                    "label": "Id",
                    "value": "4202"
                },
                "currency": {
                    "label": "Currency",
                    "value": "$"
                }
            }
}

				
			
Error Response :
  • Code: 401 BAD REQUEST
  • Content:
				
					{
  "code": 401,
  "message": "fail",
  "data": {
    "error": "Invalid API Token"
  }
}

				
			
Note :

Code Examples :

JavaScript Code (Fetch API) :
				
					fetch("http://<server-ip-address>/custom_api/export_capex_details/capex_disbursement_spend_timeline?capex_id=1&data_from_timestamp=1&current_page=1", {
  method: "GET",
  headers: {
    "Authorization": "Bearer <Token>"
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.log("Error:", error));

				
			
PHP Code :
				
					$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://<server-ip-address>/custom_api/export_capex_details/capex_disbursement_spend_timeline?capex_id=1&data_from_timestamp=1&current_page=1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer <Token>"
  ),
));

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error: $error";
} else {
  echo $response;
}

				
			
curl Cammand :
				
					curl -H "Authorization: Bearer <Token>" -X GET "http://<server-ip-address>/custom_api/export_capex_details/capex_disbursement_spend_timeline?capex_id=1&data_from_timestamp=1&current_page=1"

				
			
Final Answer :

This documentation provides a detailed overview and examples for the DISBURSEMENT TIMELINE API, describing its URL, methods, parameters, and responses. Code examples are provided in JavaScript, PHP, and cURL for easy implementation.