Set allow_guest=True but I got You do not have enough permissions to complete the action 403

Ok, I set a function with @frappe.whitelist (allow_guest=True) however when I call it from the /api/method/…function? I get “You do not have enough permissions to complete the action”. Would someone know that I may be missing? Thanks

How is your method look like?
You may need to also set some parameters when querying data or inserting data.

def download_pdf(doctype, name, format=None, doc=None, no_letterhead=0):
html = frappe.get_print(doctype, name, format, doc=doc, no_letterhead=no_letterhead)
frappe.local.response.filename = “{name}.pdf”.format(name=name.replace(" “, “-”).replace(”/", “-”))
frappe.local.response.filecontent = get_pdf(html)
frappe.local.response.type = “pdf”

then… in view
var url = frappe.urllib.get_full_url(“/api/method/(module.doctype.)download_pdf?”
+ “doctype=” + encodeURIComponent(cur_frm.doc.doctype)
+ “&name=” + encodeURIComponent(
+ “&format=” + encodeURIComponent(cur_frm.meta.default_print_format)
+ “&status=” + encodeURIComponent(“Opened”)
+ “&no_letterhead=0”);

frappe.get_print() may need some additional permission.

1 Like

It is possible, I will try it, thank you very much for answering me.

1 Like

@Ignais_La_Paz_Trujil You do not need to make any changes in code, just add a role “Guest” with read and print permissions, in Role permission manager.