Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • 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
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

API Integration example

Subscribe

Get notified when there's activity on this post

This question has been flagged
apiexample
20 Replies
57325 Views
Avatar
Yves Goldberg

I am looking for example on how to integrate an external application that provides an API.

i.e. I get a json object from that external application after a request in the form of:

GET ONE: curl -u username:password http://server.com:2222/api/user/1234

Is there a module that show how I would use that collected data and use it in Odoo?


TIA

1
Avatar
Discard
Akhil P Sivan

Hi, whether the application has REST api? Anyway, If you are getting a json object, you can use "loads()" of json library to convert it as a dictionary. Then you can extract the required data from that dictionary and do whatever you need using a python function.

Avatar
Axel Mendoza
Best Answer

You could use something like this(this is an api test model that I create):

from openerp.osv import fields, osv
import requests

class solt_http_test(osv.osv): _name = 'solt.http.test' _columns = { 'name': fields.char('URL', size=1024), 'method': fields.selection([('post', 'POST'), ('get', 'GET'), ('put', 'PUT'), ('patch', 'PATCH'), ('delete', 'DELETE')], string='HTTP Method'), 'user': fields.char('User', size=64), 'password': fields.char('Password', size=64), 'content': fields.text('Content'), 'response': fields.text('Response'), } def action_request(self, cr, uid, ids, context=None): for test in self.browse(cr, uid, ids,context): auth = None if test.user and test.password: auth = (test.user,test.password) headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} result = getattr(requests, test.method)(test.name, test.content, auth=auth, headers=headers) test.write({'response':result.text}) return True solt_http_test()

Modify this for your convenience. Here is the views, action and menu i use:

        <record id="solt_http_test_form_view" model="ir.ui.view">
<field name="name">solt.http.test.form</field>
<field name="model">solt.http.test</field>
<field name="arch" type="xml">
<form string="HTTP Test" version="7.0">
<header>
<button name="action_request" string="Test" type="object" icon="gtk-go-forward"/>
</header>
<sheet layout="auto">
<group colspan="6">
<field name="name"/>
<field name="method"/>
<field name="user"/>
<field name="password"/>
</group>
<group>
<field name="content"/>
</group>
<group>
<field name="response"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="solt_http_test_tree_view" model="ir.ui.view">
<field name="name">solt.http.test.model.tree</field>
<field name="model">solt.http.test</field>
<field name="arch" type="xml">
<tree string="HTTP Test" version="7.0">
<field name="name"/>
<field name="method"/>
</tree>
</field>
</record>
<record id="solt_http_test_action" model="ir.actions.act_window">
<field name="name">HTTP Tests</field>
<field name="res_model">solt.http.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="API Tests" id="solt_rest_weaver_menu" parent="base.menu_administration" sequence="5"/> 
<menuitem name="HTTP Tests" id="solt_http_test_submenu" parent="solt_rest_weaver_menu" action="solt_http_test_action" sequence="2"/>



3
Avatar
Discard
ABU K

Hi All, What information I can pass in this fields ,I mean URL HTTP Method User Password Content Response 'name': fields.char('URL', size=1024), 'method': fields.selection([('post', 'POST'), ('get', 'GET'), ('put', 'PUT'), ('patch', 'PATCH'), ('delete', 'DELETE')], string='HTTP Method'), 'user': fields.char('User', size=64), 'password': fields.char('Password', size=64), 'content': fields.text('Content'), 'response': fields.text('Response'),

ABU K

Can you explain with an example?

Axel Mendoza

Just install it packaged in a module and use it throw the view, for example with url like http://google.com, and method get

ABU K

I got this Error result = getattr(requests, test.method)(test.name, test.content, auth=auth, headers=headers) TypeError: get() takes exactly 1 argument (4 given)

ABU K

When I try using GET Method ...

ABU K

I try with google.com, and method is GET ,but i got above error also here what is the username=? and password=? Need a help...........Axel

Axel Mendoza

The error of get that takes 1arg and received 4 is related to the version that you are using of requests. You need to adjust to the http methods signature of your requests version. The username and password refers to http basic auth

Avatar
Shinu
Best Answer

If you need any support in Odoo Integration, please refer https://www.confianzit.com/odoo-integration

0
Avatar
Discard
Avatar
stanislav ploschansky
Best Answer

Alex,  thank you for posting this. I'm a newbie in Odoo and need to integrate auto action to our system (asap as usually:) 
I'm stucked currently with initial step:
    import requests
It gives me following error:
   Odoo Server Error - Validation Error: forbidden opcode(s) in 'import Requests': IMPORT_NAME.

Could someone give me a hint how to enable using "requests"?

0
Avatar
Discard
Axel Mendoza

requests is this library at: http://docs.python-requests.org

you need to install it first,

pip install requests

should works

stanislav ploschansky

Thank you for answer! But ... is that possible to do for free edition of Odoo? Is there some kind of sandbox to install external modules?

Axel Mendoza

Yes, of course, Odoo is Open Core so as long as you know what you do you could do anything

stanislav ploschansky

that's cool! But i'm using Odoo like https://my.odoo.com, so where is console to install module? Or should I use Install Model from UI menu (which expect ZIP file) and prepare it first from docs.python-requests.org?

Axel Mendoza

No way then to do it, since you don't have the permissions to do the required installs and customizations

stanislav ploschansky

arg... bad news. Could you recommend some else way to have automated actions for integration purpose? I need to setup some trigger on changes in Odoo and hit another system then. Or only the way is have own installation of Odoo?

Axel Mendoza

Your issue doesn't seems to be with requests, since that library is included as a python dependency in requirements.txt

The issue seems to be in the place where your code is located or the way it's loaded. Maybe it's because you are importing the module or something. Maybe you need to install on promise or on own your cloud server vps

stanislav ploschansky

OK, thank you once again! I'll try find a way to continue.

Avatar
Yves Goldberg
Author Best Answer

Thank you Axel

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How do I get Product Prices with json API? Solved
api
Avatar
Avatar
1
नव॰ 25
2756
Has anyone integrated Helpdesk with Zoom for meeting scheduling?
api
Avatar
Avatar
1
अग॰ 25
1352
Using API check if Odoo is using Odoo sh or on-premises hosting. Solved
api
Avatar
Avatar
1
अग॰ 25
1730
External API XMLRPC Authentication Keeps Replying with false
api
Avatar
Avatar
Avatar
2
जुल॰ 25
4658
API xmlrpc - upload pdf bills to account Solved
api
Avatar
Avatar
Avatar
3
जुल॰ 25
1823
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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