Learn R Programming

r311 (version 0.4.4)

o311_ok: Is open311 API ok?

Description

Checks whether an open311 API mounted by o311_api is reachable and returns a valid requests response.

Usage

o311_ok(error = FALSE)

Value

A logical describing whether the API is reachable or not. If error = TRUE, returns the corresponding error object if one occurs.

Arguments

error

[logical]

Whether to return a logical or the error message describing why the API is not ok.

Examples

Run this code
# \donttest{
# check if Bonn API is reachable
o311_api("Bonn")
o311_ok()

o311_api("Helsinki, FI")
o311_ok()

# check if Savonlinna API is reachable - should fail
o311_add_endpoint(
  name = "Savonlinna, FI",
  root = "https://savonlinna.asiointi.fi/eFeedback/api/georeport/v2"
)

o311_api("Savonlinna, FI")

# return error message
try(o311_ok(error = TRUE))

# reset endpoints database
o311_reset_endpoints()
# }

Run the code above in your browser using DataLab