Difference between revisions of "Integration/REST"

From TempusServa wiki
Jump to navigation Jump to search
old>Admin
m (→‎Version 2 (Json): Swagger UI)
 
(28 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This article has not yet been converted to Wiki format.
== Introduction to the REST interface ==
 
The rest interface has two versions.
* v1, XML-version (default)
* v2, JSON-version
 
 
== Version 1 (XML) ==
 
This article has not yet been fully converted to Wiki format.


Please download the original article: [http://www.tempusserva.dk/articlebase/Tempus%20Serva%20REST%20interface.pdf Tempus Serva REST interface.pdf]
Please download the original article: [http://www.tempusserva.dk/articlebase/Tempus%20Serva%20REST%20interface.pdf Tempus Serva REST interface.pdf]


=== Netbeans quick start guide ===
=== Netbeans quick start guide ===
Line 9: Line 17:
# Add Webservice to ide (wadl import)
# Add Webservice to ide (wadl import)
#* URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].wadl
#* URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].wadl
#* If import causes trouble: Download the wadl file
# Create a new project
# Create a new project
## Add REST Client to project
## Add REST Client to project
Line 14: Line 23:
## Add JAXB bindings to project (use XSD schema)
## Add JAXB bindings to project (use XSD schema)
##* URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].xsd
##* URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].xsd
##* If import causes trouble: Download the xsd file
==== Sample code for list view (BASIC athentication) ====
<syntaxhighlight lang="java">
//Create session
FirmabilerClient session = new FirmabilerClient();
session.setUsernamePassword("admin", "password1223");
//Set search parameters (first parameter is a dummy)
FirmabilerList result = session.getList(FirmabilerList.class, "", "TITEL=Kasper" );
//Retrieve data and print
List <FirmabilerListItem> list = result.getFirmabilerListItem();
for(int i=0; i<list.size(); i++) {
    //Handle single item
    FirmabilerListItem item = list.get(i);
    System.out.println( item.getDataID() + "\t" + item.getNUMMERPLADE() );
}
//Close connection
session.close();
</syntaxhighlight>
==== Sample code for list view (parameter credentials) ====
<syntaxhighlight lang="java">
//Create session
FirmabilerClient session = new FirmabilerClient();
//Login and set search parameters
FirmabilerList result = session.getList(FirmabilerList.class, "admin", "password1223", "TITEL=Kasper" );
//Retrieve data and print
List <FirmabilerListItem> list = result.getFirmabilerListItem();
for(int i=0; i<list.size(); i++) {
    //Handle single item
    FirmabilerListItem item = list.get(i);
    System.out.println( item.getDataID() + "\t" + item.getNUMMERPLADE() );
}
//Close connection
session.close();
</syntaxhighlight>
== Version 2 (Json) ==
Download the swagger file from:
<syntaxhighlight lang="ini">
https://<server>/<application>/rest/v2/swagger.json
</syntaxhighlight>
You can browse and try the api, using the built in SwaggerUI (from version 9147):
<syntaxhighlight lang="ini">
https://<server>/<application>/rest/v2/swagger
</syntaxhighlight>
== URL structure ==
When logged in the following URLs are available without further authentication
Data list operations: GET, PUT, POST
<syntaxhighlight lang="ini">
http(s)://<server>/<application>/rest/<version>/<entity>
</syntaxhighlight>
Data item operations: GET, PUT, POST, DELETE
<syntaxhighlight lang="ini">
http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>
</syntaxhighlight>
File list operations: PUT, POST
<syntaxhighlight lang="ini">
http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>/<FieldName>/
</syntaxhighlight>
File item operations: GET, PUT, POST, DELETE
<syntaxhighlight lang="ini">
http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>/<FieldName>/<FileName>
</syntaxhighlight>


==== Sample code for list view ====
=== Executing codeunit ===


    //Create session
Operations: GET, PUT, POST, DELETE
    FirmabilerClient session = new FirmabilerClient();


    //Login and set search parameters
<syntaxhighlight lang="ini">
    FirmabilerList result = session.getList(FirmabilerList.class, "admin", "password1223", "TITEL=Kasper" );
http(s)://<server>/<application>/rest/<version>/codeunit/<codeunitName>
</syntaxhighlight>


    //Retrieve data and print
=== Query parameters ===
    List <FirmabilerListItem> list = result.getFirmabilerListItem();
    for(int i=0; i<list.size(); i++) {
        //Handle single item
        FirmabilerListItem item = list.get(i);
        System.out.println( item.getDataID() + "\t" + item.getNUMMERPLADE() );
    }


    //Close connection
The REST API supports the same filtering and search parameters, as the list-command [[Integration/Content_source]].
    session.close();

Latest revision as of 13:04, 30 May 2024

Introduction to the REST interface

The rest interface has two versions.

  • v1, XML-version (default)
  • v2, JSON-version


Version 1 (XML)

This article has not yet been fully converted to Wiki format.

Please download the original article: Tempus Serva REST interface.pdf

Netbeans quick start guide

Steps to create a simple interaction

  1. Add Webservice to ide (wadl import)
    • URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].wadl
    • If import causes trouble: Download the wadl file
  2. Create a new project
    1. Add REST Client to project
      • Point to newly created webservice: [SolutionSystemName]
    2. Add JAXB bindings to project (use XSD schema)
      • URL: [ServerName]/[ApplicationName]/rest/[SolutionSystemName].xsd
      • If import causes trouble: Download the xsd file


Sample code for list view (BASIC athentication)

//Create session
FirmabilerClient session = new FirmabilerClient();
session.setUsernamePassword("admin", "password1223");

//Set search parameters (first parameter is a dummy)
FirmabilerList result = session.getList(FirmabilerList.class, "", "TITEL=Kasper" );

//Retrieve data and print
List <FirmabilerListItem> list = result.getFirmabilerListItem();
for(int i=0; i<list.size(); i++) {
    //Handle single item
    FirmabilerListItem item = list.get(i);
    System.out.println( item.getDataID() + "\t" + item.getNUMMERPLADE() );
}

//Close connection
session.close();

Sample code for list view (parameter credentials)

//Create session
FirmabilerClient session = new FirmabilerClient();

//Login and set search parameters 
FirmabilerList result = session.getList(FirmabilerList.class, "admin", "password1223", "TITEL=Kasper" );

//Retrieve data and print
List <FirmabilerListItem> list = result.getFirmabilerListItem();
for(int i=0; i<list.size(); i++) {
    //Handle single item
    FirmabilerListItem item = list.get(i);
    System.out.println( item.getDataID() + "\t" + item.getNUMMERPLADE() );
}

//Close connection
session.close();


Version 2 (Json)

Download the swagger file from:

https://<server>/<application>/rest/v2/swagger.json

You can browse and try the api, using the built in SwaggerUI (from version 9147):

https://<server>/<application>/rest/v2/swagger

URL structure

When logged in the following URLs are available without further authentication

Data list operations: GET, PUT, POST

http(s)://<server>/<application>/rest/<version>/<entity>

Data item operations: GET, PUT, POST, DELETE

http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>

File list operations: PUT, POST

http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>/<FieldName>/

File item operations: GET, PUT, POST, DELETE

http(s)://<server>/<application>/rest/<version>/<entity>/<DataID>/<FieldName>/<FileName>

Executing codeunit

Operations: GET, PUT, POST, DELETE

http(s)://<server>/<application>/rest/<version>/codeunit/<codeunitName>

Query parameters

The REST API supports the same filtering and search parameters, as the list-command Integration/Content_source.