Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    Real Estate
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    Consulting
    • Accounting Firm
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • Solar Energy Systems
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    Others
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

Controller not working

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
controllers
2 ตอบกลับ
1779 มุมมอง
อวตาร
Moses Mwaba

Hey guys please help. I have created a controller in odoo17 and when try to POST a request using postman I am getting the error below.

2025-06-23 08:15:22,702 18051 INFO ? werkzeug: 127.0.0.1 - - [23/Jun/2025 08:15:22] "POST /api/student/create HTTP/1.1" 404 - 1 0.003 0.042



I have also imported my file in the __init__.py

from . import student_api_controller

Here is the url I am using in postman
http://localhost:8069/api/student/create

Here is my controller 

from odoo import http
from odoo.http import request
import json
import urllib
import logging

_logger = logging.getLogger(__name__)


class StudentAPI(http.Controller):

@http.route('/api/student/create', type='http', auth='public', methods=['POST'], csrf=False)
def create_student(self, **kw):
try:
# Manually parse JSON data from the request body
data = json.loads(request.httprequest.data.decode('utf-8'))

# Ensure the data is a list
if not isinstance(data, list):
response = {"success": False, "error": "Data should be a list of students."}
return request.make_response(json.dumps(response), headers={'Content-Type': 'application/json'})

study_mode_mapping = {
'Distance': 'distance',
'Fulltime': 'full_time',
'Parttime': 'part_time'
}

nationality_mapping = {
'Local': 'local',
'SADC': 'sadc',
'International': 'international'
}

responses = []
for student_data in data:
for key in student_data:
if isinstance(student_data[key], str):
student_data[key] = urllib.parse.unquote_plus(student_data[key])

_logger.info("Received data: %s", student_data)

study_mode = student_data.get('study_mode')
if study_mode:
student_data['study_mode'] = study_mode_mapping.get(study_mode, 'distance')

nationality = student_data.get('nationality')
if nationality:
student_data['nationality'] = nationality_mapping.get(nationality, 'local')

required_fields = ['student_id', 'government_id', 'address', 'study_mode', 'email', 'name', 'mobile', 'nationality']
missing_fields = [field for field in required_fields if field not in student_data]
if missing_fields:
responses.append({"success": False, "error": f"Missing fields: {', '.join(missing_fields)}"})
continue

taken_reg = request.env['res.partner'].sudo().search([
('government_id', '=', student_data.get('government_id')),
('is_student', '=', True)
], limit=1)

taken_id = request.env['res.partner'].sudo().search([
('student_id', '=', student_data.get('student_id')),
('is_student', '=', True)
], limit=1)

if taken_id:
responses.append({"success": False, "error": "Another Student with this Student ID already exists!"})
continue

if taken_reg:
responses.append({"success": False, "error": "Another Student with this Government ID already exists!"})
continue

student = request.env['res.partner'].sudo().create({
'is_student': True,
'student_id': student_data.get('student_id'),
'government_id': student_data.get('government_id'),
'street': student_data.get('address'),
'study_mode': student_data.get('study_mode'),
'email': student_data.get('email'),
'name': student_data.get('name'),
'mobile': student_data.get('mobile'),
'nationality': student_data.get('nationality'),
})

responses.append({'success': True, 'student_id': student.id})

return request.make_response(json.dumps(responses), headers={'Content-Type': 'application/json'})

except Exception as e:
_logger.error("Error processing request: %s", str(e))
response = {"success": False, "error": str(e)}
return request.make_response(json.dumps(response), headers={'Content-Type': 'application/json'})
​
0
อวตาร
ละทิ้ง
อวตาร
Cybrosys Techno Solutions Pvt.Ltd
คำตอบที่ดีที่สุด

Hi,

If you're getting a 404 error when trying to POST to a custom route in Odoo 17, make sure your controller is defined correctly. Here's a working example:


from odoo import http

from odoo.http import request

import json


class StudentController(http.Controller):


    @http.route(

        '/api/student/create',

        type='http',

        auth='public',

        csrf=False,

        methods=['POST'],

        cors='*'

    )

    def create_student(self, **kw):

        response = {'message': 'success'}

        return request.make_response(json.dumps(response), status=200)



Also, make sure to add a dbfilter in your odoo.conf file. Without it, the request may not map to the correct database, especially if you're running in a multi-database environment.


Hope it helps

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

Hii,

Please check 
The file is located in your module’s /controllers/ directory.
The controller file is imported in your module's __init__.py like this:

directory like :
your_module/controllers/__init__.py

from . import controllers


Check Route Matching:

@http.route('/api/student/create', type='http', auth='public', methods=['POST'], csrf=False)

Make sure you're using exact match in Postman:

  • URL should be http://localhost:8069/api/student/create (adjust port as needed).
  • Method must be POST.

Testing Route:

@http.route('/api/test', type='http', auth='public', methods=['GET'], csrf=False)

def test_api(self, **kw):

    return "It works!"

 i hope it is use full


0
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
Controller giving 404 Error
controllers
อวตาร
อวตาร
อวตาร
2
ส.ค. 25
3274
How to add simple logic inside methods of Odoo 16 website controller?
controllers
อวตาร
อวตาร
อวตาร
3
มิ.ย. 24
4560
Controller or middleware that handles all the requests
controllers
อวตาร
อวตาร
1
มี.ค. 23
4732
Controller for auto fill
controllers
อวตาร
0
เม.ย. 17
3611
Custom controllers not working
controllers
อวตาร
0
มี.ค. 15
4786
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now