Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- url = 'http://localhost:8069/odoo/test'
- headers = {'Content-Type': 'application/json'}
- data = {
- 'name': 'Jane',
- 'email': 'jane.doe@gmail.com',
- }
- data_json = json.dumps(data)
- r = requests.post(url=url, data=data_json, headers=headers)
- import openerp.http as http
- from openerp.http import Response
- import logging
- _logger = logging.getLogger(__name__)
- class WebFormController(http.Controller):
- @http.route('/odoo/test', type='json',
- auth='public', methods=['POST'], website=True)
- def index(self, **args):
- _logger.info('CONNECTION SUCCESSFUL')
- _logger.info(args)
- name = args.get('name', False)
- email = args.get('email', False)
- _logger.info(name)
- _logger.info(email)
- if not name:
- Response.status = '400 Bad Request'
- return '{"response": "OK"}'
- r = requests.post(url=url, json=data_json, headers=headers)
- data = {
- "params": {
- "name":"prakashsharma",
- "email":"prakashsharmacs24@gmail.com",
- "phone":"+917859884833"
- }
- }
- curl -i -X POST -H "Content-Type: application/json" -d '{"params": {"name":"prakashsharma","email":"prakashsharmacs24@gmail.com","phone":"+917859884833"}}' 'http://localhost:8069/web/yourlistoner/'
- import requests
- headers = {
- 'Content-Type': 'application/json',
- }
- data = '{"params": {"name":"prakashsharma","email":"prakashsharmacs24@gmail.com","phone":"+917859884833"}}'
- requests.post('http://localhost:8069/web/yourlistoner/', headers=headers, data=data)
- from odoo import http
- import json
- class YourClass(http.Controller):
- @http.route('/web/yourlistoner/', type='json', auth="none", methods=['POST'],cors="*", csrf=False)
- def listoner(self, **kw):
- print http.request.params
- print "lllllllllllllllllllll"
- return json.dumps({"result":"Success"})
Add Comment
Please, Sign In to add comment