Community archives des diffusions par email

community@mail.odoo.com

Avatar

Re: REST API

par
Akretion, Raphael Valyi
- 06/11/2017 14:10:40
Hello,
you may eventually be interrested by ooorest: https://github.com/akretion/ooorest
It is a Rails microservice that will expose the Odoo ORM via REST. 
It is based on ooor which emulates the Rails ActiveRecord API for Odoo 
using the JSONRPC API under the hood.
And once we have an ActiveRecord API, Rails is able to talk REST out of the box,
no need to re-invent the wheel.

Regards.



On Mon, Nov 6, 2017 at 7:55 PM, Stefan Becker <ich@funbaker.de> wrote:
Hello,

This code will eventually lead to problems, as it is not catching errors and will not close the connection.

Better use requests, which is a requirement of odoo anyway, and which takes care of those details.

>>> import requests
>>> reply = requests.post("{{URL}}", json={...}).json()

Am Montag, den 06.11.2017, 17:30 +0000 schrieb GHANDI Othmane:
You can use this

import json
import urllib2
url = "http://ip_address:8080/WsClient/ServiceClient/odooClient"
body = {
"informationsFlux": {
"nom": "Othmane"
}
}
req = urllib2.Request(url=url, data=json.dumps(body), headers={
"Content-Type": "application/json",
})
reply = json.load(urllib2.urlopen(req))
print 'reply +++++++++++++++++++++++++++++++++++', reply

Good luck

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
Raphaël Valyi
Founder and consultant

Référence