콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
8811 화면

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
6348
2
12월 24
1225
1
11월 22
2577
2
8월 22
6874
1
2월 22
3348