diff --git a/oml/oxtornado.py b/oml/oxtornado.py index b34cdfe..23b4b91 100644 --- a/oml/oxtornado.py +++ b/oml/oxtornado.py @@ -83,9 +83,18 @@ class ApiHandler(tornado.web.RequestHandler): context = self._context if context is None: context = defaultcontext - action = request.arguments.get('action', [None])[0].decode('utf-8') - data = request.arguments.get('data', [b'{}'])[0] - data = json.loads(data.decode('utf-8')) if data else {} + action = None + if request.headers.get('Content-Type') == 'application/json': + try: + r = json.loads(request.body.decode()) + action = r['action'] + data = r['data'] + except: + action = None + if not action: + action = request.arguments.get('action', [None])[0].decode('utf-8') + data = request.arguments.get('data', [b'{}'])[0] + data = json.loads(data.decode('utf-8')) if data else {} if not action: methods = list(actions.keys()) api = []