Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

How to get JSON data in an Odoo controller using type='json'?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
jsonrequest
4 Replies
44882 Tampilan
Avatar
Kathy - {T}


In Odoo 11,

I have written a Web Controller to accept JSON data, as follows

class XController(http.Controller):

    @http.route('/test', type='json', auth='public', methods=['POST'], csrf=False)
    def test(self, **post):
        _logger.info('CONNECTION SUCCESSFUL!!')
        _logger.info(post)
        name = post.get('name', False)
        if not name:
            Response.status = '400 Bad Request'
        return '{"response": "OK"}'

Now when I post the data using the following Request, I get JSON Post data correctly without any issues.

headers = {'Content-Type': 'application/json'}
data = {"params" : { 'name': 'Kathy'} }
data_json = json.dumps(data) r = requests.post(url=url, data=data_json, headers=headers)

However since this request is made from an external system, the format of data is sent as follows,

data = {'name': 'Katty'}

ie without params inside data/content, Due to which, my post data is empty, how do I handle this.


Any help appreciated.

4
Avatar
Buang
Sehrish

Odoo Controllers
1- https://learnopenerp.blogspot.com/2018/06/odoo-get-web-form-template-value-in-controller.html
2- https://learnopenerp.blogspot.com/2018/08/odoo-web-controller.html

Avatar
Ravi Gadhia
Jawaban Terbai

you can directly intercept the werkzeug request object and get data from it 
like
        data = json.loads(request.httprequest.data)
you can also get use:  request.httprequest.args


9
Avatar
Buang
Kathy - {T}
Penulis

Thank Goodness, you saved me...

Ravi Gadhia

Cool :)

Fotis Paraskevopoulos

Hello Ravi,

Can you provide some resources on how to intercet the werkzeug request in Odoo *before* this line.

https://github.com/odoo/odoo/blob/f1a5ad5f20bf1b885a3c2dc2248b8fb15b2d6565/odoo/http.py#L613

I don't have control over the callback payload, except that it is in JSON

Avatar
Victor Inojosa
Jawaban Terbai

Get it with the jsonrequest attribute

from odoo.http import request

...

data = request.jsonrequest
1
Avatar
Buang
Avatar
Duane Ellis
Jawaban Terbai

Odoo mi sembra un sistema abbastanza interessante.

0
Avatar
Buang
Duane Ellis

Posso leggere le sue caratteristiche qui https://basketballstarsgame.io

Avatar
Jainesh Shah(Aktiv Software)
Jawaban Terbai

Hello Kathy,

Please refer below link:

https://stackoverflow.com/questions/37111955/how-to-get-json-data-in-an-odoo-controller-using-type-json

Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   ​

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Selecting a specific db for a json request
json request jsonrpc
Avatar
0
Mar 17
5309
information request
request
Avatar
Avatar
1
Jun 24
2298
name 'json' is not defined
json
Avatar
0
Jan 21
13852
V8 : authentification JSON query has changed ? [SOLVED] Diselesaikan
json
Avatar
Avatar
2
Des 19
10481
json.dumps returns 'true' string instead of 'True', which makes problem with Python
json
Avatar
Avatar
1
Apr 17
13502
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik 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