From 27242059556dbca3cb98de6b7e2135c68c069e1f Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 17 Dec 2017 00:31:11 +0530 Subject: [PATCH] Handle content_type application/json in request --- frappe/app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/app.py b/frappe/app.py index 76d7113742..4c6acc3538 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -121,8 +121,15 @@ def init_request(request): frappe.local.http_request = frappe.auth.HTTPRequest() def make_form_dict(request): + import json + + if request.content_type == 'application/json': + args = json.loads(request.data) + else: + args = request.form or request.args + frappe.local.form_dict = frappe._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \ - for k, v in iteritems(request.form or request.args) }) + for k, v in iteritems(args) }) if "_" in frappe.local.form_dict: # _ is passed by $.ajax so that the request is not cached by the browser. So, remove _ from form_dict