Try ERPNext Buy Support Partners Foundation

Rest API for Employee Checkin

Hi Community,
I was trying to create a POST request for Employee Checkin but encountered the following :
frappe.exceptions.ValidationError: No Employee found for the given employee field value. ‘attendance_device_id’: ‘HR-EMP-00005’
PS: I do have employee ‘HR-EMP-00005’ in my system.
Screenshot%20from%202020-07-23%2013-30-19

Am i missing out something??

I tried posting data using Postman on to
https://stsdemo.erpnext.com/api/method/erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field

In headers:

Authorization:token access key:secret key

Status received:

417 EXPECTATION FAILED

Traceback:
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/app.py”, line 64, in application
response = frappe.api.handle()
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/api.py”, line 58, in handle
return frappe.handler.handle()
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/handler.py”, line 30, in handle
data = execute_cmd(cmd)
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/handler.py”, line 69, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/init.py”, line 1085, in call
return fn(*args, **newargs)
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/erpnext/erpnext/hr/doctype/employee_checkin/employee_checkin.py”, line 61, in add_log_based_on_employee_field
frappe.throw(_(“No Employee found for the given employee field value. ‘{}’: {}”).format(employee_fieldname,employee_field_value))
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/init.py”, line 396, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable)
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/init.py”, line 375, in msgprint
_raise_exception()
File “/home/frappe/benches/bench-version-13-2020-07-02/apps/frappe/frappe/init.py”, line 326, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: No Employee found for the given employee field value. ‘attendance_device_id’: HR-EMP-00003

Hello,

Check your fields again. I think the key is not employee_field_value but employee.

Try to check the source code also. You need to pass on employee_fieldname the field you want to match with.

Regards,

Ivan

1 Like

Hey Thanks.
Yes i had missed employee_fieldname.

1 Like

I’m trying the same thing here. But I do not understand what really is employee_field_value.

Please help me if you guys understand this and help me in getting a successful response from this REST API.
Thanks