Skip to Content
HTTP Request Log
HTTP Request Log

HTTP Request Log

by Kitworks Systems
FREE
Odoo Apps Dependencies base, bus, http_routing
Community Apps Dependencies
Technical Name kw_http_request_log
License LGPL-3
Website https://github.com/kitworks-systems/addons
Versions 14.0 15.0 16.0 17.0 18.0 19.0

HTTP Request Log

This module provides functionality to log and track HTTP requests in Odoo. It allows storing and managing HTTP request logs with their sources, making it easier to monitor and analyze HTTP traffic in your Odoo instance.

Key features include:

  • HTTP Request Logging: Log incoming HTTP requests with detailed information
  • Source Management: Track different sources of HTTP requests
  • Automatic Cleanup: Configurable automatic deletion of old logs
  • Request Body Storage: Smart handling of request bodies with file storage for large payloads

Developer Guide

Configuration

Create a Log Source:
source_id = env['kw.http.request.log.source'].create({
    'name': 'My API Integration',
    'code': 'my_api',
    'active': True,
    'keep_days': 30,  # Keep logs for 30 days
})

Logging Requests

Basic Request Logging:
env['kw.http.request.log'].create_in_new_transaction({
    'log_source_id': source_id.id,
    'request_method': 'POST',
    'request_url': 'https://api.example.com/endpoint',
    'request_headers': {'Content-Type': 'application/json'},
    'request_body': '{"key": "value"}',
    'response_status': 200,
    'response_body': '{"status": "success"}'
})
Using with HTTP Controller:
from odoo import http
from odoo.http import request

class MyController(http.Controller):
    @http.route('/my/api/endpoint', type='json', auth='public')
    def handle_request(self, **kwargs):
        source = request.env['kw.http.request.log.source'].sudo().search(
            [('code', '=', 'my_api')], limit=1)
        
        request.env['kw.http.request.log'].sudo().create_in_new_transaction({
            'log_source_id': source.id,
            'request_method': request.httprequest.method,
            'request_url': request.httprequest.url,
            'request_headers': dict(request.httprequest.headers),
            'request_body': request.httprequest.data.decode(),
            'response_status': 200,
            'response_body': json.dumps(response_data)
        })
        
        return response_data

Features Details

  • Large Request Bodies:
    • Bodies larger than 10KB are automatically stored in attachment files
    • Access the full body content through the body_content computed field
  • Automatic Cleanup:
    • Logs are automatically deleted based on source's keep_days setting
    • Configure the cleanup schedule in ir.cron settings
  • Error Handling:
    • Use error_message field for storing error descriptions
    • Set is_error flag for failed requests

Bug Tracker

Bugs are tracked on https://kitworks.systems/requests. In case of trouble, please check there if your issue has already been reported.

Maintainer

KitWorks Systems. Our web site: https://kitworks.systems

We can provide you further Odoo Support, Odoo implementation, Odoo customization, Odoo 3rd Party development and integration software, consulting services. Our main goal is to provide the best quality product for you.

For any questions contact us.