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

Hello, everyone!

So, I have a little question. I need to consume an external API provided by a client from my company. I'm searching a lot and I can't find how to do this, the only thing I can manage to find is how to develop an API to be consumed by others, but I need the exact opposite. I just want to take some info I have and be able to send data to this external API. I really hope that someone could help me, 'cause I'm pretty confused on how to do it. If there are some documentation or anything on this that could help me, I appreciate.
I have even looked in the controllers and all that odoo.http stuff session, but I didn't understood a lot and don't actualy know if this is the case of using it.

If somebody could help me, I really appreciate it.

OBS: As I've said in the title, I'm using the version 11 of Odoo

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

you need python-requests library get or post data to external API
https://requests.readthedocs.io/en/master/
In standard odoo code, there are many examples available. just global search `requests.post` or requests.get` keyword you will find many examples like
https://github.com/odoo/odoo/blob/11.0/addons/google_drive/models/google_drive.py#L95

Note: there is no need to write any controller for it you can use it anywhere in the codebase


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Not sure what exactly you are looking for, If you are looking how to fetch the data from Odoo database, you can go through the odoo documentation:  External API

Along with it, to fetch value and update in the database, you can make use of the controllers too, see an example here: https://www.youtube.com/watch?v=wGvuRbCyytk

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 19
2533
0
thg 2 24
3549
1
thg 6 24
1307
1
thg 11 23
4004
1
thg 3 23
5508