What is Rest API?
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.
...
A RESTful API breaks down a transaction to create a series of small modules. Each module addresses a particular underlying part of the transaction. This modularity provides developers with a lot of flexibility.
How to set up Burti Rest API?
It is necessary to create script in server folder {{run-burti-web-api-requests.sh}} that will contain requests to the server, using the {{curl}} command-line tool:
Code Block |
---|
curl "http://localhost:1402/Web_JSON_Composer.hal" -d @sample.get.data.txt > response.get1.json curl "http://localhost:1402/Web_JSON_Composer.hal" -d @sample.get.data2.txt > response.get2.json curl "http://localhost:1402/Web_JSON_UpdatingComposer.hal" -d @sample.post.data.txt > response.post.json |
curl "http://localhost:1402/Web_JSON_Composer.hal" -d @sample.get.data.txt > response.get1.json
curl "http://localhost:1402/Web_JSON_Composer.hal" -d @sample.get.data2.txt > response.get2.json
curl "http://localhost:1402/Web_JSON_UpdatingComposer.hal" -d @sample.post.data.txt > response.post.json
{code}The requests are as follows:
h4. Request full details for a specific Item
{{sample.get.data.txt
}} - made to the READ interface {{Web_JSON_Composer.hal
}}:{
Code Block |
---|
...
0_query=Web_JSON_INVc_List.hal&0_full=true&0_index=Code&0_Code=10101&0_company=1&0_fieldcnt=1&0_fieldlist=Code |
{code}
h5. Parameters explained
As you can see, all the parameters are prefixed with a {{"0_"}} - this is a number for the request, and is used to make multiple data requests within a single API call. In this example, there is only one data request.
# {{query}} - the specific data interface (will be a separate interface for each register). In this case it's "Web_JSON_INVc_List.hal" for Items (register code {{INVc}}) - the naming of this interface will be the same accross all registers.
# {{full}} - whether to request the full data or a shorter list of fields - these fields are configured separately
# {{index}} - the index in Hansaworld's datadef, by which to lookup the data, advanced topic, simply use "Code" (might be something other for other registers)
# {{Code}} - the field name within the index, simply use "Code" (might be something other for other registers)
# {{fieldcnt}} - number of fields within the index, use 1 (might be something other for other registers)
# {{company}} - the company number from which we are requesting the data
# {{fieldlist}} - list of the fields within the index, comma separated, use "Code" (might be something other for other registers)
...