The current construction of the curl command does not escape nested quotes.
The httr::POST function deals with it nicely. The list of parameters can be passed as it is without needing to care about quotes.
params <- list(
TAG = "QMA2.Formula:FisherExperience",
ITER = "200",
WARMUP = "300",
YEAR = "2025",
FY_FACT = "ClientNumber",
PCELR_BY_DAY = "TRUE",
CLASS = "FALSE",
OFFSET = "TRUE",
CATCH = "FALSE",
FS_REGIONS = "TRUE",
COREAREA = "5",
DIVERYR = "5",
CLIENTYR = "5",
FSTRING = "
bf(log(GreenweightKgQuantity/nSA) | weights(1/nSA) ~ LP + NLP, nl=T) +
lf(LP ~ (1 | ClientNumber) + RS + (1 | FishingYear) + (1 | RS:FishingYear) + (1 | CatcherId) + lFD + (1 | StatisticalAreaCode)) +
nlf(NLP ~ log(((inv_logit(a*FY))-0.5)*2)) + lf(a~1)
",
QMA = "2",
PSTRING = "
set_prior('normal(0,5)', class = 'sd', nlpar = 'LP') +
set_prior('normal(0,5)', class = 'sigma') +
set_prior('normal(3.5,10)', coef = 'Intercept', nlpar = 'LP') +
set_prior('normal(0,5)', class = 'b', nlpar = 'LP') +
set_prior('lognormal(0, 2)', nlpar = 'a')
"
)
response <- httr::POST(
url = "https://kahawai.io/job/PAU-CPUE-STD-SM",
httr::add_headers(Authorization = sprintf('Bearer %s', JWT),
"Content-Type" = "application/json"),
body = list(env = params),
encode = "json"
)
if (httr::http_error(response)) {
stop("Job triggering failed: ", httr::http_status(response)$reason)
} else {
message("Job triggered successfully!")
}
The current construction of the curl command does not escape nested quotes.
The
httr::POSTfunction deals with it nicely. The list of parameters can be passed as it is without needing to care about quotes.