Skip to content

Level 2 Uplaod API

Automatic reimport of Level-2 data

Besides the manual upload via the web frontend of the DMP (menu item Logger > Manual Uplaod) there is the possibility to import the Level 2a or Level 2b data automatically into the DMP. The interface is realized via the HTTP protocol and corresponds to a POST-request in which the data file is transmitted as a parameter of the request. Furthermore, only one file can be transmitted per call. The URLs for the call contain the device ID to identify the logger:

  • Level 2a data

    https://logger-worker.intranet.ufz.de/gateway/uploadl2a/device/<DEVICE_ID>
    
  • Level 2b data

    https://logger-worker.intranet.ufz.de/gateway/uploadl2b/device/<DEVICE_ID>
    

The name of the parameter for the data is "file".

Example implementations

Python

import requests

device_id = 'fffffffffff'
file = 'test.csv

paramter = 'file
base_url = 'https://logger-worker.intranet.ufz.de/gateway/uploadl2b/device/'
url = base_url + device_id

response = requests.post(url, files={
        paramter: open(file, 'rb')
    })

ret = response.json()
success = response.status_code == requests.codes.ok

if len(ret['content']):
    print(ret['content'])

if not success and len(ret['exception']):
    print(ret['exception'])
    exit(1)

Curl/Bash

#!/usr/bin/env bash

FILE="/tmp/testl2b.csv"
DEVICE_ID="fffffffffff"

BASE_URL="https://logger-worker.intranet.ufz.de/gateway/uploadl2b/device/"
URL="${BASE_URL}${DEVICE_ID}"

curl "$URL" -sf -F "file=@${FILE}" > /dev/null
exit $?
</pre>

Powershell

$file = "C:_tmp\testl2b.csv"
$deviceid = "fffffffffffff"
$base_url = "http://logger-worker.intranet.ufz.de/gateway/uploadl2b/device/"

$url = $base_url + $deviceid
$webClient = New-Object System.Net.WebClient;

$webClient.UploadFile($url, "POST", $file);