Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
9361 Lượt xem

Hi all,

I need to connect my nodemcu/arduino device with my odoo server via internet to pass sensor values for odoo custom module. but i unable to create a bridge with odoo and nodemcu. so anyone know about these please give me simple example. looking for the positive response guys!

Cheers!  

Ảnh đại diện
Huỷ bỏ

Can you make HTTP requests (GET, POST) from your Arduino to any server?

Tác giả

yes definitely i can

Câu trả lời hay nhất

Odoo provides External API: 

https://www.odoo.com/documentation/11.0/webservices/odoo.html

But it uses XML-RPC and I think it is not easy to implement xml-rpc client on Arduino.

The reason I ask if you can send http requests from Arduino it is you can easily create an simple HTTP endpoint on Odoo, without XML-RPC at all. What you need is a custom Controller: https://www.odoo.com/documentation/11.0/reference/http.html

Something like this:

class ApiController(http.Controller):
@http.route('/api/dost/', methods=['post'], auth='public', csrf=False)
  def create_order(self, **kw):
# Play with stuff, E.g:
#env = http.request.env
#werkzeug_request = http.request.httprequest
#werkzeug_request.get_data()
#str_data = werkzeug_request.data
# and other parameters, please read Odoo document
return "ok"

A few things to notice:

auth='public' : because you will not want Odoo to ask Arduino about authentication (username, password)

csrf=False: to disable csrf protection. You may consider another method to secure your API endpoint.

Now you can send a http from Arduino to http://your.com:8069/api/dost

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for the information Thanh Loyal

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
3620
1
thg 7 25
1718
1
thg 8 25
1153
0
thg 5 25
2066
2
thg 4 25
4365