flink rest api错误:请求与预期的格式jarrunrequestbody不匹配

3b6akqbq  于 2021-06-21  发布在  Flink
关注(0)|答案(2)|浏览(404)

尝试使用下面的restapi远程运行flink作业,但其抛出错误

curl -X POST -H 'Content-Type: application/json' --data '
{
    "type": "object",
    "id": "urn:jsonschema:org:apache:flink:runtime:webmonitor:handlers:JarRunRequestBody",
    "properties": {
    "programArgsList" : {
      "type" : "array",
      "items" : [
        "input-kafka-server": "****",
        "input-kafka-topics": "****",
        "input-job-name": "****"

    }
  }
}
' http://x.x.x.x:8081/jars/810ac968-5d5f-450d-aafc-22655238d617.jar/run

{“errors”:[“请求与预期格式jarrunrequestbody不匹配。”]}
提前谢谢。

ep6jt1vc

ep6jt1vc1#

如果有人正在寻找python代码通过restapi提交flink作业。

import json

url = base_url + "/jars/" + jar_id + "/run"
    myheader = {'content-type': 'application/json'}
    mydata = {
        "programArgsList": [
                            "--input-kafka-server", "value-input-kafka-server",
                            "--input-kafka-topics", "value-kafka-topics",
                            "--input-job-name","value-job-name"
                            ],
        "parallelism": 30
    }
    x = requests.post(url, data=json.dumps(mydata), headers=myheader)
ghg1uchk

ghg1uchk2#

您在这里找到的jar run处理程序的请求体的描述是jar run消息的json模式规范。您需要在请求中指定的只是 properties 而不是 "type" 以及 "id" 领域。因此,您的请求应该如下所示:

curl -X POST -H 'Content-Type: application/json' --data '
{
  "programArgsList" : [
    "--input-kafka-server",
    "value-input-kafka-server",
    "--input-kafka-topics",
    "value-kafka-topics",
    "--input-job-name",
    "value-job-name"
  ],
"parallelism": 30
}
' http://x.x.x.x:8081/jars/810ac968-5d5f-450d-aafc-22655238d617.jar/run

相关问题