Search code examples
apache-flinkflink-streaming

Flink REST API POST error while trying to start a new job using the uploaded jar


I am trying to hit the /jars/:jarid/run endpoint to start a Flink job as follows after reading up this SO post -

curl -k -v -X POST -H "Content-Type: application/json" --data '
{
    "programArgsList": [
        "--runner",
        "FlinkRunner",
        "--inputTopicName",
        "inputTopicNameValue",
        "--Argument",
        "Value",
        "--streaming",
        "true"]
}
' http://<JobManager-hostname>:<port>/jars/MyApplication.jar/run

I get the following error when I try the above command -

{"errors":["Internal server error.","<Exception on server side:\norg.apache.flink.client.program.ProgramInvocationException: The main method 
caused an error: Argument 'FlinkRunner' does not begin with '--'\n\tat 
org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:546)\n\tat 
org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)\n\tat 
org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:83)\n\tat 
org.apache.flink.client.program.PackagedProgramUtils.createJobGraph(PackagedProgramUtils.java:80)

Argument 'FlinkRunner' does not begin with '--' leads me to think that argument values are not being provided correctly in my example. I understand that the Flink documentation provides the JSON schema definition and not the sample request in the REST API docs. What is the correct way to provide argument values? My example is following what the accepted solution suggested in this post.


Solution

  • The following POST request worked for me so I am documenting it here -

    curl -k -v -X POST -H "Content-Type: application/json" --data '
    {
        "programArgsList": [
            "--runner=FlinkRunner",
            "--inputTopicName=inputTopicNameValue",
            "--Argument=Value",
            "--streaming=true"]
    }
    ' http://<JobManager-hostname>:<port>/jars/MyApplication.jar/run