I'm building a plugin in intellij and want to make a curl request. The plugin is written in kotlin.
The following curl request works:
val comd = arrayOf(
"curl",
"-X",
"GET",
"-H",
"Authorization: AUTH_TOKEN",
"https://api.bitrise.io/v0.1/me"
)
But the following POST request with data doesn't:
val comd = arrayOf(
"curl",
"-X",
"POST",
"https://api.bitrise.io/v0.1/apps/appslug/builds",
"-H",
"Authorization: AUTH_TOKEN",
" -d $data"
)
I'm using this function to run the request:
private fun executeCommandLine(project: Project, comd: Array<String>) {
val process = Runtime.getRuntime().exec(comd)
val processHandler: ProcessHandler = OSProcessHandler(process, "clear", Charset.forName("UTF-8"))
consoleView.attachToProcess(processHandler)
processHandler.startNotify()
}
It just throws an error:
curl: (3) nested brace in URL position 18:
-d {"hook_info":{"type":"bitrise"},"build_params":{"branch":"master"}}
I've tried running the request with -g switch for globbing error. But then I run into another one:
curl: (3) URL using bad/illegal format or missing URL
What am I missing here?
PS: I've had to break my curl command into an array otherwise it doesn't work. Check this: Unable to execute CURL command through java Runtime.getRuntime().exec()
Thanks in advance :)