Getting 404 Error for web controller
in Postman http://localhost:8017/school/schoolrecords
File name: controller/controllers.py
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class StudentController(http.Controller):
@http.route('/school/schoolrecords', type='http', auth='public', methods=['GET'])
def getSchoolRecords(self):
school_rec = request.env['school.student'].sudo().search([])
school=[]
for rec in school_rec:
vals={
'id':rec.classid
}
school.append(vals)
return {'student':school}
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
Hii,
Odoo routes returning JSON should set type='json' or return a Response object (not just a dictionary).
Also, you are using type='http' but returning a plain Python dictionary. For JSON responses, it's better to either:
- Use type='json' (automatic JSON serialization)
- Or manually return a Response with headers
here is updated code
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
import json
class StudentController(http.Controller):
@http.route('/school/schoolrecords', type='json', auth='public', methods=['GET'])
def get_school_records(self):
school_rec = request.env['school.student'].sudo().search([])
school = []
for rec in school_rec:
school.append({
'id': controllers.py
i hope it is use full
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Olİlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
Controller not working
Çözüldü
|
|
2
Haz 25
|
572 | |
|
3
Haz 24
|
3385 | ||
|
1
Mar 23
|
3804 | ||
|
0
Nis 17
|
2960 | ||
|
0
Mar 15
|
4017 |