{% call register_example('r', 'button_label') %} R {% endcall %} {% call register_example('r', 'request_limit') %}
library(httr2)
req <- request("{{ h.url_for('api.action', logic_function='datastore_search', qualified=True) }}")
result <- req %>%
req_headers(Authorization = API_TOKEN) %>%
req_body_json(list(
resource_id = '{{ resource_id }}',
limit = 5,
q = 'jones'))
req_perform %>%
resp_body_json
{% endcall %}
{% call register_example('r', 'request_filter') %}
library(httr2)
req <- request("{{ h.url_for('api.action', logic_function='datastore_search', qualified=True) }}")
result <- req %>%
req_headers(Authorization = API_TOKEN) %>%
req_body_json(list(
resource_id='{{ resource_id }}',
filters = list(
subject = list("watershed", "survey"),
stage = "active")))
req_perform %>%
resp_body_json
{% endcall %}
{% call register_example('r', 'request_sql') %}
library(httr2)
req <- request("{{ h.url_for('api.action', logic_function='datastore_search_sql', qualified=True) }}")
result <- req %>%
req_headers(Authorization = API_TOKEN) %>%
req_body_json(list(
sql = "SELECT * FROM \"{{resource_id}}\" WHERE title LIKE 'jones'"))
req_perform %>%
resp_body_json
{% endcall %}
{% block custom %}{% endblock %}