Frappe API gives data inside 'message' ,is it possible to change it somehow?

Frappe API gives data inside
message’ in its json response ,is it possible to change it somehow like make it
{
‘data’:{
}
status_code:CODE,
message:Message
Status:True
}
?and throw proper errors in permission error case?

API v2 is WIP, it will give data in data key

You can still return raw response from your function and it will sent as is. Checkout werkzeug response object.

2 Likes

Can you please elaborate more on this…like what it is and how to get it working?

For anyone looking for the raw response using werkzeug, the answer is mentioned here.

For custom functions/endpoints you can use werkzeug Response object

import json
from werkzeug.wrappers import Response

@frappe.whitelist()
def my_custom_endpoint():
	data = {"foo": "bar"}
	response = Response(json.dumps(data), content_type='application/json')
	response.status_code = 200
	return response