call_endpoint: Call an API Endpoint with Optional File Upload

View source: R/client.R

call_endpointR Documentation

Call an API Endpoint with Optional File Upload

Description

Sends an HTTP request to a specified API endpoint using the stored bearer token for authentication, optionally supporting file uploads.

Usage

call_endpoint(method, endpoint, params = list(), data = NULL, files = NULL)

Arguments

method

The HTTP method (e.g., "GET", "POST", "PUT", "DELETE").

endpoint

The API endpoint.

params

A named list of query parameters (optional).

data

A named list or 'JSON' object to include in the request body (optional).

files

A list of files to upload, where each file is a named list with 'name', 'path', and optionally 'type'.

Value

A list containing the API response.

Examples

## Not run: 
response <- call_endpoint("POST", "/api/projects/upload", files = list(
  list(name = "file1", path = "path/to/file1.txt", type = "text/plain"),
  list(name = "file2", path = "path/to/file2.csv", type = "text/csv")
))
print(response)

## End(Not run)

viafoundry documentation built on Aug. 23, 2025, 1:11 a.m.