コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
9303 ビュー

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})
アバター
破棄
関連投稿 返信 ビュー 活動
2
1月 19
6707
2
12月 24
2267
1
11月 22
3435
2
8月 22
7801
1
2月 22
4026