I am trying to provide a R function as a web service for which I am using https://blogs.msdn.microsoft.com/mlserver/2018/07/26/dockerizing-r-and-python-web-services/ as a reference.
I changed my function accordingly so that it should accept a dataframe. I want to consume the web service through curl. How do I pass a dataframe to publishService function through curl?
I tried send the dataframe as a JSON so that curl POST should accept it as a string, but it isn't accepting.
library(mrsdeploy)
library(jsonlite)
manualTransmission <- function(hp, wt) {
hp <- jsonlite::fromJSON(hp)
wt <- jsonlite::fromJSON(wt)
c(hp[1,1],wt[1,1])
}
remoteLogin("http://localhost:12800", username = "admin", password =
"Microsoft@2018", session = FALSE)
api <- publishService("ManualTransmissionService", code =
manualTransmission, inputs = list(hp = "character", wt = "character"),
outputs = list(answer = "vector"), v = "1.0.0")
The command:
curl --header "Content-Type: application/json" --header "Authorization: Bearer <accesstoken>" --request POST --data "{\"hp\": \"[{\"hp_col\": 5}]\",\"wt\": \"[{\"wt_col\": 5}]\"}" http://localhost:12800/api/ManualTransmissionService/1.0.0