Access post data from within Server Script (Type: API)

How can I get the value from the body of a post request within API created via Server Script?

For example, if my request post data is as below:

{
"name" : "someone",
"country": "India"
}

How can I get the value in the request from within server script? I tried the below way with no success.

country = frappe.request.POST.get('country')
frappe.response['message'] =  country

Server Script in Frappe:

Request an the error:

Error Text:
"exception":"TypeError: 'NoneType' object is not callable"

1 Like

Found the solution. The below code worked:

 data = frappe.form_dict.country
 frappe.response['message'] =  data

Server Script that worked:

Postman request & response screenshot:

2 Likes