Hi,
I am using an external application SurveyCTO for data collection purpose. The data collected has to come to R through API. But I am unable to fetch the API. In the reprex, I have not put the username and password. But when I gave the username and password, it does not work. The code runs, but I get error. I have attached the screenshot of the data frame. How can I resolve this?
library(tidyverse)
library(httr)
#> Warning: package 'httr' was built under R version 4.1.3
#API Request with digest authentication
request <-
GET("https://earlyspark.surveycto.com/api/v2/forms/data/wide/json/EarlySpark_Baseline_Assessment_2022_23?date=0",
authenticate("username","password"))
#retrieve the contents of a request as a character vector
data_text <- content(request, "text")
#convert from JSON data to R object
data <- fromJSON(data_text, flatten = TRUE)
#> Error in fromJSON(data_text, flatten = TRUE): could not find function "fromJSON"
Created on 2022-10-14 by the reprex package (v2.0.1)