Track Invoice Fields

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 ParametersRequired
format=json (In the future, maybe change to default)Yes

Form Data Parameters :

KeyValue
page_namecapex_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 : Notice Message! Your message here

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>'

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top