问题
I have Spring XD job already deployed which expects 2 jobParameter
s (absoluteFilePath
and fileName
). Actually this job is triggered by JMS stream whose output provides those 2 jobParameter
s in JSON format and that works fine. I want to launch the job with REST API like:
curl -X POST http://localhost:9393/jobs/executions?jobname=loadData&jobParameters=%7B%22absoluteFilePath%22%3A%22C%3A%2FUB%2Fdev%2FBM.txt%22%2C%22fileName%22%3A%22BM.txt%22%7D
Error I'm getting: 'jobParameters' is not recognized as an internal or external command, operable program or batch file.
Wondering if there is anything wrong with CURL command or if jobParameters
is not supported?
I'm able to launch a job without jobParameter
s with the following CURL command, but as the job expects parameters it fails.
curl -X POST http://localhost:9393/jobs/executions?jobname=loadData
回答1:
Have you tried launching via the XD shell? It sends the jobName
and jobParameters
in the request body...
public void launchJob(String name, String jobParameters) {
String uriTemplate = resources.get("jobs/executions").toString();
MultiValueMap<String, Object> values = new LinkedMultiValueMap<String, Object>();
values.add("jobParameters", jobParameters);
values.add("jobname", name);
restTemplate.postForObject(uriTemplate, values, Object.class);
}
This looks like an OS shell message; try adding '...' around the URL.
Google makes me think this is on Windows (not sure where you're getting curl from); for Windows, you'll probably need "...".
(The problem is the &
).
来源:https://stackoverflow.com/questions/29971057/spring-xd-rest-api-job-launch-with-jobparameters-responding-with-jobparameters