Community
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("https://www.formstack.com/api/v2/form/", form_id, "/field.json")
Payload
payload <- sprintf(
"{"hide_label":false,
"description_callout":false,
"required":false,
"readonly":false,
"hidden":false,
"uniq":false,
"colspan":1,
"sort":null,
"field_type":"number",
"label":"%s",
"decimals":2,
"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.
Regards,
Ray