You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 徐涛 <ha...@gmail.com> on 2018/11/12 04:45:43 UTC
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":"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
Re: Any examples on invoke the Flink REST API post method ?
Posted by 远远 <zh...@gmail.com>.
hi,
http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/cancel-with-savepoint-404-Not-Found-td19227.html
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 <ga...@data-artisans.com> 于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 <ya...@gmail.com> wrote:
>
>> Hi Henry,
>>
>> Maybe Gary can help you, ping him for you.
>>
>> Thanks, vino.
>>
>> 徐涛 <ha...@gmail.com> 于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
>>>
>>
Re: Any examples on invoke the Flink REST API post method ?
Posted by Gary Yao <ga...@data-artisans.com>.
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 <ya...@gmail.com> wrote:
> Hi Henry,
>
> Maybe Gary can help you, ping him for you.
>
> Thanks, vino.
>
> 徐涛 <ha...@gmail.com> 于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
>>
>
Re: Any examples on invoke the Flink REST API post method ?
Posted by vino yang <ya...@gmail.com>.
Hi Henry,
Maybe Gary can help you, ping him for you.
Thanks, vino.
徐涛 <ha...@gmail.com> 于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
>