Skip to Content
Menu
This question has been flagged
2 Replies
2970 Views

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)
Avatar
Discard
Author

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",

}

Related Posts Replies Views Activity
7
Jan 24
40514
0
Feb 21
2537
1
Jan 20
7808
0
Apr 17
2157
2
Feb 23
1702