Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5291 Lượt xem

I am using Trello webhooks to synchronize Odoo project module, In order to create a webhook, I have to first validate the controller in Odoo and if the controller successfully returned then Trello will start sending data to the same controller which I have used for verification but the issue is during controller verification, Trello called the controller using HTTP type and after validation they send data to the same controller called by JSON type, which I am not sure how to achieve.

So basically during validation, it should be the controller.

@http.route('/trello/webhook',type="http", auth='public')
def trelloWebhook(self, **kwagrs):
pass

and after verification, It should be like this

@http.route('/trello/webhook',type="json", auth='public') 
def trelloWebhook(self, **kwagrs):
pass
How to handle same controller for two different types.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can create two controllers like this to solve.

    @http.route('/trello', type='http', auth="none", methods=['GET'], csrf=False)
    def trello_webhook_test(self, **kwargs):
        res = request.httprequest
        if res.method == 'HEAD':
            return ''
    
    @http.route('/trello', type='json', auth="none", methods=['POST'], csrf=False)
    def trello_webhook_response(self, **kwargs):
        res = request.jsonrequest and request.jsonrequest or {}
        # your code...
          
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 21
5631
0
thg 2 21
2323
0
thg 7 19
216
2
thg 12 18
4007
5
thg 11 18
7535