This article will guide you on how to create a time code through BioStar 2 TA API.
* A new API for Time Attendance has been added with BioStar v2.8.13. *
For a more general introduction to TA API (including how to access the TA Swagger), please refer to the link below:
[BioStar 2 TA API] Introduction BioStar 2 TA API
For other articled related to BioStar 2 TA Time Codes:
[BioStar 2 TA API] Search Time Codes
[BioStar 2 TA API] Modify Time Codes
[BioStar 2 TA API] Delete Time Codes
One of the most basic parts of BioStar 2 TA is the Time Code.
As you can see in the below screenshot, you can create a time code through the BioStar 2 Web UI.
This article will show you how to do the same action through API.
Part 1. API Parameters
[POST]: /tna/pay_codes
This API creates a new time code.
[Body Parameters]
Parameters | Type | Required | Description |
---|---|---|---|
accumulate_toward_overtime | Boolean | Y | True for overtime management |
color | String | Y | Color of time code |
count_as_attendance | Boolean | Y | True for attendance management |
description | String | N | Description |
name | String | Y | Name of time code |
time_rate | Double | Y | 0-10 rate |
track_on_leave_management | Boolean | Y | True for leave management |
type | String | Y | ["WORKED" , "NOT_WORKED"] |
Part 2. Request Body & Response Model
[Example Value/Parameters Model]
{ "accumulate_toward_overtime": false, "color": "#00ff00", "count_as_attendance": true, "description": "Made by API", "name": "Time Code Made by API", "time_rate": 1, "track_on_leave_management": false, "type": "WORKED" } |
[Response: successful]
{ "id": 5, "message": "Created successfully", "message_key": "CREATED", "language": "en", "status_code": "CREATED" } |
[Response: Fail: missing required input]
{ "message": "type is required.", "message_key": "REQUIRED_FIELD", "language": "en", "status_code": "REQUIRED_FIELD" } |
Part 3. POST /tna/pay_codes via Postman
[Request Example: Headers]
*You must log-in to T&A to use [POST] /tna/pay_codes
*Unlike be-session-id for AC New Local API, bs-ta-session-id is sent in the Cookie automatically once you log-in via TA log-in API. So there's no need for you to save and update it separately.
[Request Example]
[Response Example: body]
After calling the API, as you can see in the BioStar web UI, there is a new time code added with the name "TESTING".