How to export biometric device log to erpnext?

Hello… I am new at erpnext, question is i have .json file contains biometric device log such as
user_id, timestamp, punch, etc…
ex:
{‘uid’: 3177, ‘user_id’: ‘5’, ‘timestamp’: datetime.datetime(2021, 3, 11, 9, 12, 40), ‘status’: 1, ‘punch’: 1}
My question is how to export .json file to my project or how to connect biometric device with erpnext project…
I have followed the steps at this link but have errors https://github.com/frappe/biometric-attendance-sync-tool

Can you attach the error traceback?

2021-03-15 14:39:50,497 ERROR Error during ERPNext API Call. 1 1225504872.0 test_1 None Traceback (most recent call last):
File “/home/frappe/bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/frappe/bench/apps/frappe/frappe/api.py”, line 43, in handle
validate_auth()
File “/home/frappe/bench/apps/frappe/frappe/api.py”, line 167, in validate_auth
validate_auth_via_api_keys(authorization_header)
File “/home/frappe/bench/apps/frappe/frappe/api.py”, line 220, in validate_auth_via_api_keys
validate_api_key_secret(api_key, api_secret)
File “/home/frappe/bench/apps/frappe/frappe/api.py”, line 234, in validate_api_key_secret
user_secret = frappe.utils.password.get_decrypted_password(“User”, user, fieldname=‘api_secret’)
File “/home/frappe/bench/apps/frappe/frappe/utils/password.py”, line 49, in get_decrypted_password
frappe.throw(_(‘Password not found’), frappe.AuthenticationError)
File “/home/frappe/bench/apps/frappe/frappe/init.py”, line 377, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable)
File “/home/frappe/bench/apps/frappe/frappe/init.py”, line 356, in msgprint
_raise_exception()
File “/home/frappe/bench/apps/frappe/frappe/init.py”, line 316, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.AuthenticationError: Password not found

2021-03-15 14:39:50,498 ERROR exception when calling pull_process_and_push_data function for device{“device_id”: “test_1”, “ip”: “192.168.1.239”, “punch_direction”: null, “clear_from_device_on_fetch”: false}
Traceback (most recent call last):
File “C:/New folder (9)/biometric-attendance-sync-tool-master/erpnext_sync.py”, line 55, in main
pull_process_and_push_data(device, device_attendance_logs)
File “C:/New folder (9)/biometric-attendance-sync-tool-master/erpnext_sync.py”, line 146, in pull_process_and_push_data
raise Exception(‘API Call to ERPNext Failed.’)
Exception: API Call to ERPNext Failed.

Hope you have set ERNEXT_API_KEY and ERPNEXT_API_SECRET of the ERPNext User properly in local_config.py. Also ensure that the User has the required permissions.

Below are the delineation of the keys contained in local_config.py:

  • ERPNext connection configs:
    • ERPNEXT_API_KEY: The API Key of the ERPNext User

    • ERPNEXT_API_SECRET: The API Secret of the ERPNext User

      Please refer to this link to learn how to generate API key and secret for a user in ERPNext.
      The ERPNext User who’s API key and secret is used, needs to have at least the following permissions:

      1. Create Permissions for ‘Employee Checkin’ DocType.
      2. Write Permissions for ‘Shift Type’ DocType.
1 Like

I tried to enter ERPNEXT_API_KEY and ERPNEXT_API_SECRET
ERPNEXT_API_KEY = ‘…’
ERPNEXT_API_SECRET = ‘…’
ERPNEXT_URL = ‘http://company.com/api/method/erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field
but still get the same error

Kindly refrain from sharing API credentials in a public forum.

After test he return this error:
frappe.exceptions.PermissionError: Not Allowed, <function add_log_based_on_employee_field at 0x7f1014204268>
Any kind of help?

As you can see this is a PermissionError, which means that the ERPNext user’s, whose API Secret is set, does not have adequate permissions.

Check that the user has Create permissions for Employee Checkin and Write permissions for Shift Type

1 Like