Back to All

Field Attribute is not changed via API

I tried to use API in R studio to modify my form. I want to create a numerical field with 2 dp and min of 0. I created a function to do so called create_fields.

create_fields <- function(api_token, form_id, label) {

API URL for adding a field

url <- paste0("", form_id, "/field.json")


payload <- sprintf(
"min_value":0}", label)

API request

response <- VERB("POST", url, body = payload, add_headers('authorization' = paste('Bearer', api_token)), content_type("application/json"), accept("application/json"),encode = "json")

Return the API response

return(cat(response$status_code,"\n",content(response, "text")))

I managed to connect to my test form but the numerical field generated just use default attributes (0 dp and no min value) rather than attributes specified in the function.