Paid and UnPaid API

Description 

 

This document gives detailed information about How to add paid and unpaid days of users via API. Records are imported with 500 max records by default, this max records can be changed from configuration. If any previous record exists for the user then that record will be updated with the new values.

 


API Endpoint

https://<your_instance>/api.php/attendance/attendancedb/pushUsersPaidUnPaidDays

Bearer Token 

 

Please refer to the token generation documentation for generating API tokens to invoke uKnowva APIs. (Token Generation Docs)

 

Method Type

 

  •  POST

Mandatory Fields

“month”,“year”,“Paid_days”,“username” 

Example Request


cURL

ccurl --location 'https://<your_instance>/api.php/attendance/attendancedb/pushUsersPaidUnPaidDays ' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer Token' \
--data '{'test' :{'month': 3,
'year': 2000,
'username': 'test',
'days_in_month': 30,
'paid_days': 24,
'unpaid_days': 7},
'test1' : {
'month': 3,
'year': 2000,
'username': 'test',
'days_in_month': 30,
'paid_days': 24,
'unpaid_days': 7
}}'

PHP Code Snippet

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_instance>/api.php/attendance/attendancedb/pushUsersPaidUnPaidDays ",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>'{"test" : {"month": 3,"year": 2000,"username": "test","days_in_month": 30,"paid_days": 24,"unpaid_days": 7},"test1" :{"month": 3,"year": 2000,"username": "test","days_in_month": 30,"paid_days": 24,"unpaid_days": 7}}',
CURLOPT_HTTPHEADER => array("Content-Type: application/json",'Authorization: Bearer Token')));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Python Code Snippet

import requests
import json
url = "https://<your_instance>/api.php/attendance/attendancedb/pushUsersPaidUnPaidDays "
payload = "{'test' :{'month': 3,\r\n'year': 2000,\r\n'username': 'test',\r\n'days_in_month': 30,\r\n'paid_days': 24,\r\n'unpaid_days': 7},\r\n'test1' : {\r\n'month': 3,\r\n'year': 2000,\r\n'username': 'test',\r\n'days_in_month': 30,\r\n'paid_days': 24,\r\n'unpaid_days': 7\r\n}\r\n}"
headers = {'Content-Type': 'application/json','Authorization: Bearer Token'}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Java Code Snippet

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{'test' :{'month': 3,'year': 2000,'username': 'test','days_in_month': 30,'paid_days': 24,'unpaid_days': 7},'test1' : {'month': 3,'year': 2000,'username': 'test','days_in_month': 30,'paid_days': 24,'unpaid_days': 7}}");
Request request = new Request.Builder()
.url("https://<your_instance>/api.php/attendance/attendancedb/pushUsersPaidUnPaidDays ")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer Token")
.build();
Response response = client.newCall(request).execute();

Payload

{“test” : {// Username Mandatory
“month”: 3,// Month Mandatory
“year”: 2000,// Year Mandatory
“username”: “test”,// Username Mandatory
“days_in_month”: 30,//Days in Month Non-Mandatory
“paid_days”: 24,// Paid days Mandatory
“unpaid_days”: 7// Unpaid days Non-Mandatory },
“test1” : {// Username Mandatory
“month”: 3,// Month Mandatory
“year”: 2000,// Year Mandatory
“username”: “test”,// Username Mandatory
“days_in_month”: 30,// Days in Month Non-Mandatory
“paid_days”: 24,// Paid days Mandatory
“unpaid_days”: 7// Unpaid days Non-Mandatory }
}

Sample Response


  • Success
  1. “All records imported successfully” for successfully importing all the records.
  2. “Bearer Token is not correct.” when the token is wrong.
  3. “No Data Present” when no data is sent.
  4. “Records count is <the_data> which is greater than allowed records <record_set_in_config>” when records to be imported are greater than the set records.
  5. “No User found with the provided <biometric_code> - ” when the API has different biometric code then the set biometric code set in config.
  6. “Either month or year not found for the - ” when no month and year are sent in the API.
  7. “Either month or year are in the wrong format, Please enter in number for - ” when the month or year is not present in numeric form.
  8. “Please provide the number of paid days for - ” when the paid days are not provided.
  9. “Error in saving data for <config_biometric_code> - ” when some mandatory fields or columns are not given while saving the data.

Sample Collection

Download Paid and Unpaid API Collection

In case you face any problems, then please write to This email address is being protected from spambots. You need JavaScript enabled to view it., our awesome support team will surely help you!

Was this Article helpful?