Skip to content

For Authenticated Users ​

This section is for authenticated users. You need to login to get an access token. The access token is required to access the data.

Login ​

Sign in with email and password to get access token.

R
library(httr)

# Credentials
email <- "something@email.de"
password <- "fdo8zsdb3rfs"

headers = c(
  'Content-Type' = 'text/plain',
  'apikey' = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzM4Nzk2NDAwLAogICJleHAiOiAxODk2NTYyODAwCn0.qnofsORUSwCd9Whx3XFbR56-k_ydI5DLDnV2AKxV37w'
)

body = paste0("{\n    \"email\": \"", email, "\",\n    \"password\": \"", password, "\"\n}")

res <- VERB("POST", url = "https://db.forstliche-umweltkontrolle.de/auth/v1/token?grant_type=password", body = body, add_headers(headers))

# get access token from json
access_token <- content(res, "parsed")$access_token

# output access token
print(access_token)

Request data ​

Request data from table derived_deadwood with access token and apikey.

R
# Request Data from table TEMPLATE
headers = c(
'apikey' = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzM4Nzk2NDAwLAogICJleHAiOiAxODk2NTYyODAwCn0.qnofsORUSwCd9Whx3XFbR56-k_ydI5DLDnV2AKxV37w',
'Authorization' = paste("Bearer", access_token, sep = " "),
'Accept-Profile' = 'derived',
'Content-Type' = 'text/csv'
)

res <- VERB("GET", url = "https://db.forstliche-umweltkontrolle.de/rest/v1/derived_deadwood?select=*", add_headers(headers))

# output data from table TEMPLATE
print(content(res, "text"))

Send data ​

Send data to table derived_deadwood with access token and apikey.

R
# create body
body <- '[{"data": "ADDED 1"}, {"data": "ADDED 2"}]'


headers = c(
'apikey' = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzM4Nzk2NDAwLAogICJleHAiOiAxODk2NTYyODAwCn0.qnofsORUSwCd9Whx3XFbR56-k_ydI5DLDnV2AKxV37w',
'Authorization' = paste("Bearer", access_token, sep = " "),
'Content-Profile' = 'derived',
'Content-Type' = 'application/json'
)

res <- VERB("POST", url = "https://db.forstliche-umweltkontrolle.de/rest/v1/derived_deadwood", body=body, add_headers(headers))

# output json response
print(content(res, "parsed"))