Can't insert new doc with guest API call

This is my code:

def create_daily_trip_logs():
		students = frappe.db.get_all('Students', filters={'status':'Active'},fields=['name','full_name'])
		for stds in students:
			doc = frappe.get_doc({
				'doctype':'Trip Logs',
				'trip_type': 'HTS'
			doc2 = frappe.get_doc({
				'doctype':'Trip Logs',
				'trip_type': 'STH'
		frappe.response["message"] ={
					'message': 'Daily Trip Logs created successfully'
	except Exception as e:
		frappe.response["message"] = {
				'error': e,
				'message':"something went wrong",

Whenever I call this script using 3rd party scheduler system (Cron Job) no ‘Trip logs’ Documents got created. I already gave permessions to Guest to create this document.

if there any thing missing in my code let me now please. Thank you all

Hi @seif_khelifi,

I haven’t idea but

To debug the issue, you can add some debugging statements to log the exception details to better understand what might be going wrong.

For example:

except Exception as e:
    frappe.log_error(str(e))  # Log the error for debugging
    frappe.response["message"] = {
        'status_key': 0,
        'error': str(e),
        'message': "something went wrong",

and also verify the permissions, field names.

I hope this helps.

Thank You!

1 Like