Add,Update,Delete,session maintenance

85 views
Skip to first unread message

piyush agrawal

unread,
May 13, 2016, 7:31:50 AM5/13/16
to tryton

Hello,


I have some few question while making API request:


1)Session Maintainance 
I make request for login (common.db.login), then make request get party list (model.party.party.search_read), it works fine & I also saved user_ID & session Key for future API request.
But even if I make requester after a second to party list (model.party.party.search_read) with saved user_id & Session_Key then it shows me error like"Not Logged"


2) Add,Update,Delete
How to make API request for Add,Update,Delete? Is there any API documentation for that?


3) GetSingleRecord
I am make request with domains like ["re_name","=","%%%s%%"], but it returns me blank Array

Cédric Krier

unread,
May 13, 2016, 8:05:03 AM5/13/16
to tryton
On 2016-05-13 04:22, piyush agrawal wrote:
> 1)Session Maintainance
> I make request for login (common.db.login), then make request get party
> list (model.party.party.search_read), it works fine & I also saved user_ID
> & session Key for future API request.
> But even if I make requester after a second to party list
> (model.party.party.search_read) with saved user_id & Session_Key then it
> shows me error like"Not Logged"

Session expires after a timeout defined in the configuration:
http://doc.tryton.org/4.0/trytond/doc/topics/configuration.html#timeout

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Cédric Krier

unread,
May 13, 2016, 8:10:03 AM5/13/16
to tryton
On 2016-05-13 04:22, piyush agrawal wrote:
> 2) Add,Update,Delete
> How to make API request for Add,Update,Delete? Is there any API
> documentation for that?

The API is defined in the documentation of each object. For example for
the Model, it is in
http://doc.tryton.org/4.0/trytond/doc/ref/models/models.html
But you have access only for the methods that are defined in __rpc__
http://doc.tryton.org/4.0/trytond/doc/ref/models/models.html#trytond.model.Model.__rpc__
which are only class methods.

When the method needs instances, you should replace with id in your
call.

Cédric Krier

unread,
May 13, 2016, 8:15:03 AM5/13/16
to tryton
On 2016-05-13 04:22, piyush agrawal wrote:
> 3) GetSingleRecord
> I am make request with domains like ["re_name","=","%%%s%%"], but it
> returns me blank Array

That means nothing match this clause.

Jean Cavallo

unread,
May 13, 2016, 8:17:13 AM5/13/16
to try...@googlegroups.com

2016-05-13 14:11 GMT+02:00 Cédric Krier <cedric...@b2ck.com>:
On 2016-05-13 04:22, piyush agrawal wrote:
> 3) GetSingleRecord
> I am make request with domains like ["re_name","=","%%%s%%"], but it

Did you try [["rec_name", "=", "%%%s%%"]] ?

Jean Cavallo
Coopengo

piyush agrawal

unread,
May 13, 2016, 9:20:03 AM5/13/16
to tryton
please check below my requested json String:

{"method":"model.party.party.search_read","params":[5,"3d9f26574f7646aea0f3a3c0fe787668",["rec_name","like","%%pp%%"],0,0,[],[],{"limit":0,"domain":["rec_name","like","%%pp%%"],"offset":0,"order":[],"fields":[]}]}

piyush agrawal

unread,
May 13, 2016, 9:20:04 AM5/13/16
to tryton
I getting result = null

piyush agrawal

unread,
May 13, 2016, 9:20:05 AM5/13/16
to tryton
Please check my requested son String:

{"method":"model.party.party.search_read","params":[5,"3d9f26574f7646aea0f3a3c0fe787668",["rec_name","like","%%pp%%"],0,0,[],[],{"limit":0,"domain":["rec_name","like","%%pp%%"],"offset":0,"order":[],"fields":[]}]}

is it something wrong with that?

piyush agrawal

unread,
May 13, 2016, 9:35:04 AM5/13/16
to tryton
Yes, I try as follow:
JSON String : {"method":"model.party.party.search_read","params":[5,"c3eb5b0501c3430d97387f25a4d0ff24",[["rec_name","like","P"]],0,20,[],[],{"limit":20,"domain":[["rec_name","like","P"]],"offset":0,"order":[],"fields":[]}]}
Result which I got

JSON: {


  "id" : 0,

  "result" : [


  ]

}



On Friday, 13 May 2016 17:47:13 UTC+5:30, Giovanni wrote:

Jean Cavallo

unread,
May 13, 2016, 9:35:16 AM5/13/16
to try...@googlegroups.com

2016-05-13 14:47 GMT+02:00 piyush agrawal <piyush...@gmail.com>:

{"method":"model.party.party.search_read","params":[5,"3d9f26574f7646aea0f3a3c0fe787668",["rec_name","like","%%pp%%"],0,0,[],[],{"limit":0,"domain":["rec_name","like","%%pp%%"],"offset":0,"order":[],"fields":[]}]}


Like I said, try double [[]] around your domain.

And at first, try a domain you know should match (like [["id", "=", <some_existing_id>]])

Jean Cavallo
Coopengo

Jean Cavallo

unread,
May 13, 2016, 9:41:33 AM5/13/16
to try...@googlegroups.com

2016-05-13 15:26 GMT+02:00 piyush agrawal <piyush...@gmail.com>:
JSON String : {"method":"model.party.party.search_read","params":[5,"c3eb5b0501c3430d97387f25a4d0ff24",[["rec_name","like","P"]],0,20,[],[],{"limit":20,"domain":[["rec_name","like","P"]],"offset":0,"order":[],"fields":[]}]}

Be careful !

[["rec_name", "like", "P"]] means [["rec_name", "=", "P"]]

try [["rec_name", "like", "P%"]] for instance

Jean Cavallo
Coopengo
Reply all
Reply to author
Forward
0 new messages