Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
15781 Vistas

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

Avatar
Descartar
Mejor respuesta

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


Avatar
Descartar
Mejor respuesta

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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
dic 19
2691
0
feb 24
3708
1
jun 24
1549
1
nov 23
4171
1
mar 23
5668