Any examples on invoke the Flink REST API post method ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Any examples on invoke the Flink REST API post method ?

徐涛
HI Experts,
I am trying to trigger a savepoint from Flink REST API on version 1.6 , in the document it shows that I need to pass a json as a request body
 "type" : "object”, 
  "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”, 
 "properties" : { 
 "target-directory" : { "type" : "string" },
 "cancel-job" : { "type" : "boolean" } 
 } 
}
So I send the following json as 
{
"type":"object”,
"id":"urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”,
"properties”:{
"target-directory":"<a href="hdfs:///flinkDsl" class="">hdfs:///flinkDsl”,
"cancel-job”:false
}
}

And I use okhttp to send the request:
val MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8")
val body = RequestBody.create(MEDIA_TYPE_JSON, postBody)
val request = new Request.Builder()
  .url(url)
  .post(body)
  .build()
client.newCall(request).execute()


but get an error  {"errors":["Request did not match expected format SavepointTriggerRequestBody.”]}
Would anyone give an example of how to invoke the post rest api of Flink?
Thanks a lot.

Best
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Any examples on invoke the Flink REST API post method ?

vino yang
Hi Henry,

Maybe Gary can help you, ping him for you.

Thanks, vino.

徐涛 <[hidden email]> 于2018年11月12日周一 下午12:45写道:
HI Experts,
I am trying to trigger a savepoint from Flink REST API on version 1.6 , in the document it shows that I need to pass a json as a request body
 "type" : "object”, 
  "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”, 
 "properties" : { 
 "target-directory" : { "type" : "string" },
 "cancel-job" : { "type" : "boolean" } 
 } 
}
So I send the following json as 
{
"type":"object”,
"id":"urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”,
"properties”:{
"target-directory":"hdfs:///flinkDsl”,
"cancel-job”:false
}
}

And I use okhttp to send the request:
val MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8")
val body = RequestBody.create(MEDIA_TYPE_JSON, postBody)
val request = new Request.Builder()
  .url(url)
  .post(body)
  .build()
client.newCall(request).execute()


but get an error  {"errors":["Request did not match expected format SavepointTriggerRequestBody.”]}
Would anyone give an example of how to invoke the post rest api of Flink?
Thanks a lot.

Best
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Any examples on invoke the Flink REST API post method ?

Gary Yao-2
Hi Henry,

What you see in the API documentation is a schema definition and not a sample
request. The request body should be:

    {
        "target-directory": "hdfs:///flinkDsl",
        "cancel-job": false
    }

Let me know if that helps.

Best,
Gary

On Mon, Nov 12, 2018 at 7:15 AM vino yang <[hidden email]> wrote:
Hi Henry,

Maybe Gary can help you, ping him for you.

Thanks, vino.

徐涛 <[hidden email]> 于2018年11月12日周一 下午12:45写道:
HI Experts,
I am trying to trigger a savepoint from Flink REST API on version 1.6 , in the document it shows that I need to pass a json as a request body
 "type" : "object”, 
  "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”, 
 "properties" : { 
 "target-directory" : { "type" : "string" },
 "cancel-job" : { "type" : "boolean" } 
 } 
}
So I send the following json as 
{
"type":"object”,
"id":"urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”,
"properties”:{
"target-directory":"hdfs:///flinkDsl”,
"cancel-job”:false
}
}

And I use okhttp to send the request:
val MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8")
val body = RequestBody.create(MEDIA_TYPE_JSON, postBody)
val request = new Request.Builder()
  .url(url)
  .post(body)
  .build()
client.newCall(request).execute()


but get an error  {"errors":["Request did not match expected format SavepointTriggerRequestBody.”]}
Would anyone give an example of how to invoke the post rest api of Flink?
Thanks a lot.

Best
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Any examples on invoke the Flink REST API post method ?

远远
it may help you. 
and for flink on yarn cancel job , "yarn-cancel" work well not "cancel"
the below python code for trigging savepoint work well.  
json = {"cancel-job": False}
r = requests.post(url, json=json)

Gary Yao <[hidden email]> 于2018年11月12日周一 下午5:33写道:
Hi Henry,

What you see in the API documentation is a schema definition and not a sample
request. The request body should be:

    {
        "target-directory": "hdfs:///flinkDsl",
        "cancel-job": false
    }

Let me know if that helps.

Best,
Gary

On Mon, Nov 12, 2018 at 7:15 AM vino yang <[hidden email]> wrote:
Hi Henry,

Maybe Gary can help you, ping him for you.

Thanks, vino.

徐涛 <[hidden email]> 于2018年11月12日周一 下午12:45写道:
HI Experts,
I am trying to trigger a savepoint from Flink REST API on version 1.6 , in the document it shows that I need to pass a json as a request body
 "type" : "object”, 
  "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”, 
 "properties" : { 
 "target-directory" : { "type" : "string" },
 "cancel-job" : { "type" : "boolean" } 
 } 
}
So I send the following json as 
{
"type":"object”,
"id":"urn:jsonschema:org:apache:flink:runtime:rest:messages:job:savepoints:SavepointTriggerRequestBody”,
"properties”:{
"target-directory":"hdfs:///flinkDsl”,
"cancel-job”:false
}
}

And I use okhttp to send the request:
val MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8")
val body = RequestBody.create(MEDIA_TYPE_JSON, postBody)
val request = new Request.Builder()
  .url(url)
  .post(body)
  .build()
client.newCall(request).execute()


but get an error  {"errors":["Request did not match expected format SavepointTriggerRequestBody.”]}
Would anyone give an example of how to invoke the post rest api of Flink?
Thanks a lot.

Best
Henry