Send data to the Labordatenbank

You can send data from an external system to the web service of a Labordatenbank import interface to import the data into the Labordatenbank.

The external system sends the data to the URL of the Labordatenbank import interface with username and password and receives a confirmation of receipt (status code) as a response.

To send data from an external system to an import interface of Labordatenbank, go to Edit Import Interface and click on "Activate HTTPS Account" (see figure) and assign a username and password for HTTP authentication (Information on HTTP Authentication).

Once the import via HTTPS is activated, data can be sent from an external system to the following URL (where X in the URL is to be replaced with the import interface number).

  • URL to which the dataset is sent: https://labordatenbank.com/demo/imports/import/X/0/https

  • Alternatively: URL with username and password: https://username:password@labordatenbank.com/demo/imports/import/X/0/https

The data format is defined in the import interface. See: Import Interfaces Overview
PHP Example Script for Transferring a CSV File to Labordatenbank

$url = "https://labordatenbank.com/demo/imports/import/X/0/https";
$username = 'abc';
$password = '********';

// Filename with sample number
$post['file'] = new CurlFile('Messdaten.csv');

// Send data
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($curl);
curl_close($curl);
echo $response;

PHP Example Script for Transferring an Image to a Sample Parameter in Labordatenbank

$url = "https://labordatenbank.com/demo/imports/import/X/0/https";
$username = 'abc';
$password = '********';

// Prepare file with sample number in filename
$post['file'] = new CurlFile('P00123.jpg');


$post['sample_name'] = 'P00123'; // Linking with a sample (alternative to filename)
$post['description'] = 'Probenabmessungen 13mm x 60mm';  // File description
$post['parametertype_id'] = 123;  // Add file to a parameter of the sample
$post['column'] = 0;  // Parameter column

// Send data
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Windows PowerShell Example Script for Automatic File Transfer from a Directory to Labordatenbank

$watchedDirectory = ".\import\"

$writeaction = {
  $moveTo = ".\imported\"

  function Import-File {
    param (
      $filePath,
      $moveTo
    )
    $uri = "https://labordatenbank.com/demo/imports/import/23/0/https"
    $user = "testuser"
    $pass = "testpassword"

    $file = Get-Item($filePath);
    $fileContent = [system.io.file]::readallbytes($filePath);

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

    $boundary = [System.Guid]::NewGuid().ToString()
    $LF = "`r`n"
    $fileEnc = [System.Text.Encoding]::GetEncoding('ISO-8859-1').GetString($fileContent);

    $body = (
      "--$boundary",
      "Content-Disposition: form-data; name=`"file`"; filename=`"$($file.Basename)$($file.Extension)`"",
      "Content-type: image/jpg",
      "",
      $fileEnc,
      "--$boundary"
    )

    $body = $body -join $LF

    try {
      Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $body
      Write-Host "File imported: ", $filePath

      # Should the file be moved after import?
      Move-Item -Path $filePath -Destination $moveTo
    } catch {
      Write-Host "Error during import:" $_.Exception.Response.StatusCode.value__
      Write-Host $_.Exception.Response.StatusDescription
    }
  }

  $path = $Event.SourceEventArgs.FullPath

  Import-File $path $moveTo
}

$finalPath = Resolve-Path $watchedDirectory

$filewatcher = New-Object System.IO.FileSystemWatcher
$filewatcher.Path = $finalPath
$filewatcher.Filter = "*.*"
$filewatcher.EnableRaisingEvents = $true

Unregister-Event -SourceIdentifier "LDB-Watcher" -ErrorAction:SilentlyContinue
Register-ObjectEvent $filewatcher "Created" -Action $writeaction -SourceIdentifier "LDB-Watcher"

while ($true) {
  Start-Sleep 5
}

Windows PowerShell Example Script for Transferring an Image to a Sample Parameter in Labordatenbank

$uri = "https://labordatenbank.com/demo/imports/import/X/0/https"

$user = "<strong class=red>abc</strong>"
$pass = "<strong class=red>********</strong>"

# Prepare file with sample number in filename
$filePath = Get-Item("./P210049.jpg");
$file = Get-Item($filePath);
$fileContent = [system.io.file]::readallbytes($filePath);

# Optional parameters
$bodyParameter = @{
    # Linking with a sample (alternative to filename)
    "sample_name" = "210052";
    # File description
    "description" = "Probenabmessungen 13mm x 60mm";
    # Add file to a parameter of the sample
    "parametertype_id" = 123456;
    # Parameter column
    "column" = 0;
}

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

$boundary = [System.Guid]::NewGuid().ToString()
$LF = "`r`n"
$fileEnc = [System.Text.Encoding]::GetEncoding('ISO-8859-1').GetString($fileContent);

$body = (
    "--$boundary",
    "Content-Disposition: form-data; name=`"file`"; filename=`"$($file.Basename)$($file.Extension)`"",
    "Content-type: image/jpg",
    "",
    $fileEnc,
    "--$boundary"
)

foreach($parameter in $bodyParameter.Keys) {
    $body += "Content-Disposition: form-data; name=`"$parameter`"$LF"
    $body += $bodyParameter.Item($parameter)
    $body += "--$boundary"
}

$body = $body -join $LF

Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $body

Last change: 06.11.2025

General information

Interfaces

Kompetenzen

AI functions

Employees

Reports

Report table editor

Introductory phase

Query reports

Orders

Samples

Templates

Customers

Client zone (optional)

Assets

Offers

Invoices

Parameters

Calculating with parameters

Webservices

Transformationscode

Test plans / limit values / specifications

Documents control

Material

Questions and answers

Equipment

Trainings

8D-report

Others

PDF templates

Supplier evaluation

File management

Processes