/

 

The manual

Self-training

Experimentation

Contact

 

Language

REST server and mail

Warning: The Storga REST interface works on the Storga server, not on the Pliant HTTP proxy. To access it, you must therefore activate the HTTP protocol on the Storga server, and access the TCP port assigned to it, and not that of the HTTP proxy.

In addition, in the general case, you must provide a user and a password at the HTTP request level.
Conversely, you don't have to define a real website with a name: you can use a URL like http: //ip_addresse:port_tcp/ storga / ...

Read a Storga report

If the state's Storga identifier is xxx / yyy / zzz, then you can read it via a REST request:

GET http://ip:port_tcp/storga/report/xxx/yyy/zzz

By default, the content of the report will be returned in JSON format, in the form of a dictionary whose key corresponds to the code of the form to which each row of the report corresponds.
For the reports which generate several lines per form, the key is the code of the form followed by a slash character followed by the code of the line of the sub table.

To retrieve a JSON file in the form of an array (without the codes of the forms), we use:

GET http://adresse_ip:port_tcp/storga/report/xxx/yyy/zzz?table

To retrieve only the codes of the files collected by the state, we use:

GET http://adresse_ip:port_tcp/storga/report/xxx/yyy/zzz?stripped

You also get the contents of the report in CSV format:

GET http://adresse_ip:port_tcp/storga/report/xxx/yyy/zzz?csv

The detail of the CSV encoding can be configured at the Storga site level, or at the state level.

Read a Storga form

If the form's Storga code is xxx / yyy / zzz, then you can extract the content from it via a REST request:

GET http://adresse_ip:port_tcp/storga/form/xxx/yyy/zzz

You can also obtain additional information about the types and versions associated with the Storga form. In Storga, types and versions are used to specify the nature of the content of the form. Is it a stock movement sheet, an invoice, an accounting entry, etc:

GET http://adresse_ip:port_tcp/storga/form/xxx/yyy/zzz?types

Edit the content of a Storga form

If the form's Storga code is xxx / yyy / zzz, then you can modify some of its fields via a REST request:

PUT http://adresse_ip:port_tcp/storga/form/xxx/yyy/zzz

You do not have to provide all of the form fields, but only those whose value you want to change.

To delete a row from a sub table of the form:

DELETE http://adresse_ip:port_tcp/storga/form/xxx/yyy/zzz/table/nom_de_la_sous_table/group/code_de_la_ligne

Create or delete a Storga form

Create a Storga form:

POST http://adresse_ip:port_tcp/storga/new_form/xxx/yyy/zzz

Warning: the code xxx / yyy / zzz is here that of a report, for which the 'Form template to be used in case of automatic creation' field in the 'Properties' context menu has been correctly filled.

Delete a Storga form:

DELETE http://adresse_ip:port_tcp/storga/form/xxx/yyy/zzz

Global variables

Read the content of a Storga field used as a global variable:

GET http://adresse_ip:port_tcp/storga/field/xxx/yyy/zzz

Change its content:

PUT http://adresse_ip:port_tcp/storga/field/xxx/yyy/zzz

Activate a Storga button from an external program

We can produce, via an external program, the same effect as a user filling in a Storga form and pressing a button in that form:

GET http://adresse_ip:port_tcp/storga/button/xxx/yyy/zzz/code_du_bouton?champ1=valeur1&champ2=valeur2

The values \u200b\u200bwhich are provided in the URL are used to temporarily modify certain fields of the form, just before pressing the button. It is a way of passing parameters to the mechanics encoded by the button.

If you want the form to process a file, you place a file field in the Storga form, whose name will be 'f' for example. In practice, with Stroga, a file control is not a field type block whose type would be file, but a file block which has a name (the name is indicated in the 'Variable name' property). The HTTP request can then deliver the content as an attachment, using the HTTP POST statement instead of HTTP GET, and specifying '? F \u003d' at the URL.In other words, the content of a file field is not provided in the URL, but as the content of the HTTP POST instruction.

The Storga form can return content to the HTTP client via the Storga 'download_file' instruction.
This content is a file, but as with Storga, we can very easily convert a character string into a text file, it is very easy, by this mechanism, to return a character string to the HTTP client.

Use a Storga form as an automatic mailbox

This direct SMTP \u003c-\u003e form interface is experimental: do not implement it in production without first contacting Hubert Tonneau

Sending by email is done using the email address xxx.yyy.zzz@ttt.storga.com where xxx / yyy / zzz is the Storga identifier of the form which will automatically process the mails on arrival, and ttt what we want. This assumes that the DNS assigns to the name ttt.storga.com the IP address of the Storga server, and that it has enabled the SMTP service.
You can also use a box name like xxx.yyy.zzz@storga.uuu where uuu is whatever you want, but always on condition that the DNS assigns the name storga.uuu the IP address of the Storga server.

The form xxx / yyy / zzz must contain a file block with a variable name, this file must have its 'Mail button name' field or its 'Attached button name' field filled with the code of the button that will be activated upon receipt of the mail.
If we use 'Mail button name', the file will contain the raw content of the mail in .eml format
If we use 'Attached button name', the file will contain only the attachment contained in the mail.

The mail protocol does not allow to provide a user and a password, therefore the page which contains the form acting as mailbox must have '*' as read right, and the Storga program which processes the mail on reception must be signed to be able to use the rights of its author.

Additional note

In the end, it is possible to build a Storga form that processes the files received indifferently in three ways:

By a slip deposited

By a REST request

As an attachment in an email