Provide data as web services for external systems

The laboratory database allows you to provide the data sets predefined in an evaluation as web services for external system access.

An external system calls up the URL of the laboratory database Webservice with username and password and gets back the data record of the evaluation.





To make an evaluation available as web services for external systems, go to Edit evaluation and select "Activate HTTP authentication" (see figure) and assign a user name and password for HTTP authentication (Information on HTTP authentication).











Once data retrieval via HTTP authentication is enabled, data can be retrieved from an external system using the following URLs (replacing the X in the URL with the number of the evaluation).



  1. Retrieval as CSV record: https://labordatenbank.com/demo/stats/view/X/https

  2. Fetch as JSON record: https://labordatenbank.com/demo/stats/view/X/https_json

  3. Fetching with variables: https://labordatenbank.com/demo/stats/view/X/https_json/VAR0/VAR1/VAR2/VAR3/VAR4/DATE/




The following values are possible for the variable DATE: today, yesterday, last_3_days, this_month, last_month, last_6_month, last_12_month, this_year, last_year



The data format is defined in the evaluation. See: Auswertung anlegen

If a transformation code is stored, the result of the transformation is transmitted.


The following is a sample code of how the retrieval of the evaluation could be implemented by an external system:



$url = "https://labordatenbank.com/demo/stats/view/X/https_json";

$username = 'abc';

$password = '***';



//Retrieve evaluation

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");

$json_data = curl_exec($curl);

curl_close($curl);

echo $json_data;




Windows PowerShell sample scripts for a download of a data set from an evaluation



The support of any scripts is not part of the standard support of the laboratory database. The examples included here are for assistance only and do not guarantee success.




Example 1



### Settings ###



$downloadDirectory = ".\download"



$uri = "http://labordatenbank.com/demo/stats/view/1/https_json"

$user = "testuser"

$pass = "testpassword"



#####################



$b64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${user}:$pass"))

$headers = @{

"Authorization" = "Basic $b64"

}



$download = Invoke-WebRequest -Uri $uri -Headers $headers -UseBasicParsing

$content = [System.Net.Mime.ContentDisposition]::new($download.Headers["Content-Disposition"])



$fileName = $content.FileName

$fullPath = Join-Path -Path $downloadDirectory -ChildPath $fileName



Invoke-WebRequest -Uri $uri -Headers $headers -OutFile $fullPath





Example 2



### Settings ###

$downloadDirectory = "XXX"

$uri = "https://labordatenbank.com/XXX/stats/view/XXX/https_json"

$user = "XXX"

$pass = "XXX"



$logFileName = "auswertungen.log"

$fullLogPath = Join-Path -Path $downloadDirectory -ChildPath $logFileName

Start-Transcript "$fullLogPath" -Append





Base64 decoding¶



$b64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${user}:$pass"))

$headers = @{

"Authorization" = "Basic $b64"

}



Download¶



$download = Invoke-RestMethod -Uri $uri -Headers $headers -UseBasicParsing

if($downloadDirectory){

foreach($entry in $download){

$downloadLink = $entry.'Download-Link'

$fileName = $entry.Dateiname

$fullPath = Join-Path -Path $downloadDirectory -ChildPath $fileName



Write-Host "<--- $fileName --->"



if(![System.IO.File]::Exists($fullPath)){

Invoke-WebRequest -Uri $downloadLink -OutFile $fullPath



if($fullPath){

Write-Host "$filename Downloaded successfully." -ForegroundColor Green

} else {

Write-Host "Error when downloading the file." -ForegroundColor Red

}



} else {

Write-Host "The file $fileName already exists!" -ForegroundColor Red

}



}



} else {

Write-Host "The path could not be found!" -ForegroundColor Red

}



Stop-Transcript

Last change: 16.01.2024

Allgemeines

Einführungsphase

Mitarbeiter

Aufträge

Proben

Probenvorlage

Berichte

Berichtstabellen Editor

Kunden

Kundenzone (optional)

Anlagen

Angebote

Rechnungen

Parameter

Rechnen mit Parametern

Schnittstellen

Webservice

Transformationscode

Prüfpläne / Grenzwerte / Spezifikationen

Dokumentenlenkung

Prüfmittel

Material

Mitarbeiterschulungen

8D-Report

Sonstiges

PDF-Vorlagen

Fragen und Antworten

Lieferantenbewertung

Dateiverwaltung

Auswertungen

Prozesse