On Tuesday, August 27, 2013 10:25:50 AM UTC-5, Pierre-Louis Bonicoli wrote:
>
> On 26/08/2013 23:21, Steve Heyns wrote:
> > I have tried to POSTing the following to localhost:8000/try
> >
> > {method:"sever.version",id:1,params:[]}
>
> Try:
> {"method": "system.server.listMethods", "id": 1, "params": [null, null]}
>
> > and I receive a 500 internal error as a response. But in the trytond log
> > file there is no errors
> [...]
> > The tryton client works fine in this respect nut how does a trace
> translate to something to be posted ? Like what does the following
> translate to ?
> >
> > INFO:tryton.rpc:common.server.version(None, None)
> >
> > I would assume that this is translated to :
> > {method:"common.server.version",id:1,params:['','']}
>
> Try:
> {"method": "common.server.version", "id":1, "params": [null, null]}
>
> You could use replace "server" by any string or use "common..version".
>
>
> Here is a Bash script which use "common.server.version" and
> "system.server.listMethods":
>
> > #!/bin/bash
> > DBNAME=demo2.8
> > HOST=https://demo.tryton.org:8000
> >
> > # Définition du contenu de la requête
> > data=$(cat <<DATA
> > {"id": 1, "method": "common.server.version", "params": [null, null]}
> > DATA
> > )
> >
> > # Envoie de la requête au serveur Tryton
> > wget -q -O - --no-http-keep-alive --post-data="$data" \
> > --header="Content-Type: text/json" --no-check-certificate \
> > $HOST
> >
> > echo
> >
> > # Définition du contenu de la requête
> > data=$(cat <<DATA
> > {"id": 1, "method": "system.server.listMethods", "params": [null, null]}
> > DATA
> > )
> >
> > # Envoie de la requête au serveur Tryton
> > wget -q -O - --no-http-keep-alive --post-data="$data" \
> > --header="Content-Type: text/json" --no-check-certificate \
> > $HOST/$DBNAME
> >
> > echo
>
> The format of JSONRPC query is:
> {
> "id": id of the request, used by response
> "method": name of the call,
> "params": [
> first parameter,
> second parameter,
> third parameter,
> ...
> ]
> }
>
>
> Requests can be categorized in two ways:
> - anonymous calls
> - authenticated calls
>
> "common.server.version" and "system.server.listMethods" are anonymous.
>
> In order to authenticate an user, you must perform the anonymous call
> "common.server.login(username, password)". If successful, this call
> returns user id and a cookie.
>
> User id and cookie are first and second parameters of authenticated
> calls. Context is the last parameter of authenticated call, it could be:
> - an empty dict
> - retrieved with authenticated call:
> model.res.user.get_preferences(user_id, cookie, True, {})
>
> An example: model "ir.model", read fields "info", "model", "name" and
> "module" records 47 and 71:
>
> > {
> > "id": 8,
> > "method": "model.ir.model.read",
> > "params":
> > [
> > 1,
> > "qdWWyL6guIJrnxTFGaWX7xc6o/BH+QnZbFcgU=",
> > [47, 71],
> > ["info", "model", "name", "module"],
> > {
> > "language": "fr_FR", "locale": {
> > "date": "%d.%m.%Y", "thousands_sep": "", "grouping": [],
> > "decimal_point": ","
> > },
> > "language_direction": "ltr", "groups": [1], "timezone": null
> > }
> > ]
> > }
>
> In order to manipulate the data, the following calls are available:
> model.<modelname>.(search|read|create|write|delete|copy)
>
> --
> Pierre-Louis
>
Thanks a lot... :)