Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
10251 มุมมอง

Hello Everyone

How can I get data from another app Java, using its webservice json

Thanks in advance

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

 

def json_rpc(url, method, params):
data = {
"jsonrpc": "2.0",
"type": method,
"params": params,
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url=url, data=json.dumps(data), headers={
"Content-Type": "application/json",
})
reply = json.load(urllib2.urlopen(req))
print reply
if reply.get("error"):
raise Exception(reply["error"])
return reply["reponse"]
@api.multi
def on_change_partner_id(self):
url = "http://192.168.1.49:8080/WsClient/ServiceClient/odooClient"
type = "POST"
params = {
"informationsFlux": {
"nom": "saad"
}
}
print json_rpc(url, type, params)
 
อวตาร
ละทิ้ง
ผู้เขียน

I tried the above code, but it didn't work !!

คำตอบที่ดีที่สุด

Hi Othmane,

To get detailed idea about the web services , you can refer the following link.

Web Service API

อวตาร
ละทิ้ง
ผู้เขียน

Hi Niyas

I already checked this official doc, it deals with webservices to get data from Odoo server.

For my case I want to get data from a third partie app, this this party has its own webservice json

You may want to study the documentation of the third party app in this case. This is obviously not an Odoo related question in that case.

ผู้เขียน

I have the webservice of the third party app [url, method, params] I should know call it from Odoo to get the wanted data.

Hope my question is clear.

I tried this, but it didn't work:

def json_rpc(url, method, params):

data = {

"jsonrpc": "2.0",

"type": method,

"params": params,

"id": random.randint(0, 1000000000),

}

req = urllib2.Request(url=url, data=json.dumps(data), headers={

"Content-Type": "application/json",

})

reply = json.load(urllib2.urlopen(req))

print reply

if reply.get("error"):

raise Exception(reply["error"])

return reply["reponse"]

def on_change_partner_id(self):

url = "http://172.16.121.175:8080/WsClient/ServiceClient/odooClient"

type = "POST"

params = {

"informationsFlux": {

"nom": "saad"

}

}

print json_rpc(url, type, params)

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 20
6417
6
ก.ค. 20
11599
1
มี.ค. 20
3498
Odoo JSON Filter and Offset Parameter แก้ไขแล้ว
5
ม.ค. 20
9605
0
มี.ค. 17
4450