Guest User

Untitled

a guest
Oct 26th, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import requests
  2. import json
  3.  
  4. url = 'http://localhost:8069/odoo/test'
  5. headers = {'Content-Type': 'application/json'}
  6. data = {
  7. 'name': 'Jane',
  8. 'email': 'jane.doe@gmail.com',
  9. }
  10. data_json = json.dumps(data)
  11. r = requests.post(url=url, data=data_json, headers=headers)
  12.  
  13. import openerp.http as http
  14. from openerp.http import Response
  15. import logging
  16. _logger = logging.getLogger(__name__)
  17.  
  18.  
  19. class WebFormController(http.Controller):
  20.  
  21. @http.route('/odoo/test', type='json',
  22. auth='public', methods=['POST'], website=True)
  23. def index(self, **args):
  24. _logger.info('CONNECTION SUCCESSFUL')
  25. _logger.info(args)
  26. name = args.get('name', False)
  27. email = args.get('email', False)
  28. _logger.info(name)
  29. _logger.info(email)
  30. if not name:
  31. Response.status = '400 Bad Request'
  32. return '{"response": "OK"}'
  33.  
  34. r = requests.post(url=url, json=data_json, headers=headers)
  35.  
  36. data = {
  37. "params": {
  38. "name":"prakashsharma",
  39. "email":"prakashsharmacs24@gmail.com",
  40. "phone":"+917859884833"
  41. }
  42. }
  43.  
  44. curl -i -X POST -H "Content-Type: application/json" -d '{"params": {"name":"prakashsharma","email":"prakashsharmacs24@gmail.com","phone":"+917859884833"}}' 'http://localhost:8069/web/yourlistoner/'
  45.  
  46. import requests
  47.  
  48. headers = {
  49. 'Content-Type': 'application/json',
  50. }
  51.  
  52. data = '{"params": {"name":"prakashsharma","email":"prakashsharmacs24@gmail.com","phone":"+917859884833"}}'
  53.  
  54. requests.post('http://localhost:8069/web/yourlistoner/', headers=headers, data=data)
  55.  
  56. from odoo import http
  57. import json
  58.  
  59. class YourClass(http.Controller):
  60. @http.route('/web/yourlistoner/', type='json', auth="none", methods=['POST'],cors="*", csrf=False)
  61. def listoner(self, **kw):
  62.  
  63. print http.request.params
  64. print "lllllllllllllllllllll"
  65. return json.dumps({"result":"Success"})
Add Comment
Please, Sign In to add comment