Permission Error: While trying to access API in server script list

Project Goal:
Building a chatbot for the CRM module. Initially, focusing to update client names in the policy doctype.
Implementation:
Developed a server script for updating client names.
Created a Python API to handle GET and POST methods.
Functionality:
API receives user input from the chatbot and updates fields based on parameters.
Issue Encountered:
Facing a permission error when executing the POST method for the Guest user.
Attempted Solution:
Tried to provide write access for guest user. But it’s not worked.
Tried to use set_user as Administrator in the server script to bypass permissions.
Error Received:
Encountered the error: “An unexpected error occurred: module has no attribute ‘set_user’.”

We’re trying this for a long time, please let me know how to solve this.

Add the argument allow_guest=True to the @frappe.whitelist() decorator for your function.

@frappe.whitelist(allow_guest=True)

The “Allow guest” checkbox was enabled in the server script it’s not working. Also, I tried to incorporate in server script, but during the API call request, it throws a “broken pipe” error page.

This is the traceback of my error:
File “/home/devcrm/frappe-bench/apps/frappe/frappe/handler.py”, line 75, in execute_cmd
server_script = get_server_script_map().get(“_api”, {}).get(cmd)
if server_script:
return run_server_script(server_script)

    try:
            method = get_attr(cmd)
    except Exception as e:
            frappe.throw(_("Failed to get method for command {0} with {1}").format(cmd, e))

    if from_async:
            method = method.queue

File “/home/devcrm/frappe-bench/apps/frappe/frappe/handler.py”, line 266, in get_attr

def get_attr(cmd):
“”“get method object from cmd”“”
if “.” in cmd:
method = frappe.get_attr(cmd)
else:
method = globals()[cmd]
frappe.log(“method:” + cmd)
return method

File “/home/devcrm/frappe-bench/apps/frappe/frappe/init.py”, line 1605, in get_attr

def get_attr(method_string: str) → Any:
“”“Get python method object from its name.”“”
app_name = method_string.split(“.”, 1)[0]
if not local.flags.in_uninstall and not local.flags.in_install and app_name not in get_installed_apps():
throw(_(“App {0} is not installed”).format(app_name), AppNotInstalledError)

    modulename = ".".join(method_string.split(".")[:-1])
    methodname = method_string.split(".")[-1]
    return getattr(get_module(modulename), methodname)

File “/home/devcrm/frappe-bench/apps/frappe/frappe/init.py”, line 548, in throw
:param is_minimizable: [optional] Allow users to minimize the modal
:param wide: [optional] Show wide modal
:param as_list: [optional] If msg is a list, render as un-ordered list.
:param primary_action: [optional] Bind a primary server/client side action.
“”"
msgprint(
msg,
raise_exception=exc,
title=title,
indicator=“red”,
is_minimizable=is_minimizable,
File “/home/devcrm/frappe-bench/apps/frappe/frappe/init.py”, line 509, in msgprint
_raise_exception()
File “/home/devcrm/frappe-bench/apps/frappe/frappe/init.py”, line 455, in _raise_exception
out = _dict(message=msg)

    def _raise_exception():
            if raise_exception:
                    if inspect.isclass(raise_exception) and issubclass(raise_exception, Exception):
                            raise raise_exception(msg)
                    else:
                            raise ValidationError(msg)

    if flags.mute_messages:
            _raise_exception()


Where is Allow Guest checkbox in Server Script Doctype?

Script type => Api