Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
9249 มุมมอง

I would like to send an http request from odoo to an external api (http://www.example.com/api), in the request I would like to send the order data such as : orderlines, total, ... and so on. 


how can I achieve that ?

อวตาร
ละทิ้ง

Did you get any answer? Have you find any solution? 

I would be happy to know.

Thank you

คำตอบที่ดีที่สุด

Hi,
Refer the url also below code
https://www.cybrosys.com/blog/configure-postman-for-sending-api-requests
https://www.cybrosys.com/blog/implementation-of-common-api-methods-in-the-odoo-15

import json
from odoo import http
from odoo.http import request, Response

class TestApi(http.Controller):
    @http.route('/Test/RestApi/fetch_sale_order', type='http', method=['POST'], auth='public', csrf=False)
    def fetch_product(self, **kwargs):
        if request.httprequest.method == 'POST':
                    """ADD YOUR CODE""""

Run route in postman
http://localhost:8018/Test/RestApi/fetch_sale_order?SaleOrder=

Hope it helps you

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi!

I think you can use the python library request.

This library has some function like post wich with you can set à dict that will be transform in JSON

requests.post("https://exemple.com/api"data={"id": my_id})
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo 11 How to update value instantly? แก้ไขแล้ว
2
ม.ค. 19
6665
2
ธ.ค. 24
2170
Hide menu for all except specific group แก้ไขแล้ว
1
พ.ย. 22
3358
Live tracking in odoo. แก้ไขแล้ว
2
ส.ค. 22
7691
1
ก.พ. 22
3980