跳至內容
選單
此問題已被標幟
2 回覆
15769 瀏覽次數

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

頭像
捨棄
最佳答案

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


頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
12月 19
2682
0
2月 24
3699
1
6月 24
1538
1
11月 23
4140
1
3月 23
5664