I am using this function to accept post request
@frappe.whitelist(allow_guest=True)
def verify(user.email, user.domain,_type='POST'):
pass
The request comes from another service and sends 2 params, user.email and user.domain. Notice the dots in parameter names, and I don’t have control to change them. Any idea how this can be done, as python is not accepting the dotted variable names?
Also related, can I use annotation like in flask to use a custom path instead of the default function name ?
Yes, that is the error I am getting. Maybe to be specific, I am trying to use ERPNext as a facebook messenger bot, i.e users interact with ERPNext using Facebook messenger. The bot protocol expects you to implement a POST method accepting hub.mode, hub.verify_token and hub.challenge parameters and my function would look like
@frappe.whitelist(allow_guest=True)
def verify(hub.mode, hub.verify_token, hub.challenge):
pass
Finding no better way, I have used a Flask server that interacts with FB and calls ERPNext in the backend, which works but would have preferred an ERPNext only design.
@RWEMA_Aimable
having protocol you can use, trick:
def verify(**kwargs):
assert 'hub.mode' in kwargs
assert 'hub.verify_token' in kwargs
assert 'hub.challenge' in kwargs
print kwargs['hub.mode']
1 Like
Another small issue. If I do return “Hello world”, Frappe returns {“message”: “Hello World” }. Is there a way around this. I would like to get just “Hello world”