Hello all,
I have made a controller and i already success sending data json body through postman in format like this (default format)
{"params": {"name": "admin", "age": "18"}}
but i need to receive data json body in format like this
{"name": "admin", "age": "18"}
can anyone tell me how to change receive format json without "params"? (i'm using odoo 10)
Please share your code also.
my code like this
class res_partner(http.Controller):
@http.route('/res_partner/create', type='json', auth="user")
def res_partner_erp(self, **post):
user = request.jsonrpckey['user']
env = request.env(user=user.id)
now = datetime.now()
partner_obj = env['res.partner']
res_partner = {}
for record in post.keys():
res_partner[record] = post[record]
res_partner['name'] = post['name']
res_partner['age'] = post['age']
result = partner_obj.create(res_partner)
return {
"id": result.id,
"code": 200,
"message": "OK",
}