Built-in Server script (type API) not allowing whitelisting a method

I would like to create webhook in Frappe v13 to integrate with a third party application.
So when something is done in that thrid party app, I would get a callback to an URL, which initiates a server script. (e.g. /api/method/test)

When this callback arrives, I have to modify a document based on the data, that was included in the request.

I created a Server Script document (used the built-in editor) with Script Type: API, but I can’t whitelist a function. It’s just an example script, I have to whitelist a method, to use the frappe.db.commit() command, to let my changes saved.

My code:
def hey():
frappe.response[‘message’] = “ok”


The result I get when sending a GET request to the endpoint /api/method/test:
Traceback (most recent call last):
File “/home/myusername/frappe-bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/myusername/frappe-bench/apps/frappe/frappe/api.py”, line 58, in handle
return frappe.handler.handle()
File “/home/myusername/frappe-bench/apps/frappe/frappe/handler.py”, line 30, in handle
data = execute_cmd(cmd)
File “/home/myusername/frappe-bench/apps/frappe/frappe/handler.py”, line 51, in execute_cmd
if run_server_script_api(cmd):
File “/home/myusername/frappe-bench/apps/frappe/frappe/core/doctype/server_script/server_script_utils.py”, line 26, in run_server_script_api
frappe.get_doc(‘Server Script’, script_name).execute_method()
File “/home/myusername/frappe-bench/apps/frappe/frappe/core/doctype/server_script/server_script.py”, line 89, in execute_method
_globals, _locals = safe_exec(self.script)
File “/home/myusername/frappe-bench/apps/frappe/frappe/utils/safe_exec.py”, line 41, in safe_exec
exec(compile_restricted(script), exec_globals, _locals) # pylint: disable=exec-used
File “”, line 1, in
File “/home/myusername/frappe-bench/apps/frappe/frappe/utils/safe_exec.py”, line 25, in default_function
raise AttributeError(f"module has no attribute ‘{key}’")
AttributeError: module has no attribute ‘whitelist’

What am I doing wrong? Is it possible to use the “@frappe.whitelist()” from the built-in server script editor?

If not, how can I implement the aformentioned webhook, that modifies a document on a request from a third party?

Thank you so much in advance!

1 Like

I found Very good solution for that someone built for me on freelancerone his profile Integrate erpnext with any system application integrate any app or api by Memo_boss | Fiverr

best regards