You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Vitaly Krivoy <Vi...@jhancock.com> on 2018/03/13 18:45:15 UTC

Error when executing NiFi REST API PUT /processors/{id} call



I am trying to update processors for a workflow, which was previously generated from a template by instantiating it. All work is done from a Java program through NiFi REST API. Template holds processors in a group. Since I know the template group name and strategy by which NiFi assigns a new group name when it instantiates a template ("Copy of " <original group name in a template>), I find instantiated group by name, get its group id and get list of processors in the group a ProcessorsEntity object. I then step through the list of processors contained in ProcessorsEntity, and for each processor set desired properties contained in  ProcessorEntity and its linked ProcessorDTO and ProcessorConfigDTO classes. I then set ClientId in the Revison object like this:
proc.getRevision().setClientId(restClient.getClientId());
Here proc is ProcessorEntity and restClient is a custom class which contains all code necessary to communicate with NiFi REST API.
At this point I am trying to update the processor through PUT/processors/{id} call, passing it modified data in ProcessorEntity, the same one that I got from ProcessorsEntity and update in place, rather than updating a copy. I figured that there is no need to do it for a DTO object.
When I execute PUT/processors/{id} call, I get an exception, which I need the help with. Here is what I see in Eclipse.
Exception when calling: ProcessorsApi#updateProcessor
Response body: Text '01/01/1970 13:04:02 EST' could not be parsed at index 2 (through reference chain: org.apache.nifi.web.api.entity.ProcessorEntity["status"]->org.apache.nifi.web.api.dto.status.ProcessorStatusDTO["statsLastRefreshed"])
io.swagger.client.ApiException: Bad Request
               at io.swagger.client.ApiClient.handleResponse(ApiClient.java:1058)
               at io.swagger.client.ApiClient.execute(ApiClient.java:981)
               at io.swagger.client.api.ProcessorsApi.updateProcessorWithHttpInfo(ProcessorsApi.java:707)
               at io.swagger.client.api.ProcessorsApi.updateProcessor(ProcessorsApi.java:692)
               at com.bdss.nifi.trickle.NiFiRestClient.updateProcessor(NiFiRestClient.java:149)
               at com.bdss.nifi.trickle.TemplateConfigurator.configureGroupProcessors(TemplateConfigurator.java:84)
               at com.bdss.nifi.trickle.MdmAzureConfigurator.configureGroup(MdmAzureConfigurator.java:89)
               at com.bdss.nifi.trickle.Deployer.deployTemplate(Deployer.java:52)
               at com.bdss.nifi.trickle.Trickle.main(Trickle.java:132)

Notes:
Everything that begins with com.bdss.nifi.trickle are classes in the Java application which I am implementing.
To access NiFi REST API I am using this REST client: https://github.com/simplesteph/nifi-api-client-java, which itself relies on Swagger.

Many thanks for any tips.


STATEMENT OF CONFIDENTIALITY The information contained in this email message and any attachments may be confidential and legally privileged and is intended for the use of the addressee(s) only. If you are not an intended recipient, please: (1) notify me immediately by replying to this message; (2) do not use, disseminate, distribute or reproduce any part of the message or any attachment; and (3) destroy all copies of this message and any attachments.

RE: Error when executing NiFi REST API PUT /processors/{id} call

Posted by Vitaly Krivoy <Vi...@jhancock.com>.
Thank you Matt. As you correctly have guessed, I was previously calling the API with original ProcessorEntity, updated in place. Switching to creating a new ProcessorEntity and only populating relevant fields fixed the issue.

From: Matt Gilman [mailto:matt.c.gilman@gmail.com]
Sent: Tuesday, March 13, 2018 3:09 PM
To: users@nifi.apache.org
Subject: Re: Error when executing NiFi REST API PUT /processors/{id} call

Vitaly,

I believe that error is being generated by Jackson which handles the JSON (de)serialization. Often times there is additional information that gets logged to your logs/nifi-user.log. Check there to see if there is anything helpful.

By any chance, are you attempting to pass the status back into the update call? The entity object holds information about the component (the configuration, the revision, status, permissions, etc). When performing an update request you only need to pass in the revision (RevisionDTO) and the configuration (ProcessorDTO). Check out the Developer Tools in your browser to see various requests in action.

Hope this helps.

Matt

On Tue, Mar 13, 2018 at 2:45 PM, Vitaly Krivoy <Vi...@jhancock.com>> wrote:



I am trying to update processors for a workflow, which was previously generated from a template by instantiating it. All work is done from a Java program through NiFi REST API. Template holds processors in a group. Since I know the template group name and strategy by which NiFi assigns a new group name when it instantiates a template (“Copy of “ <original group name in a template>), I find instantiated group by name, get its group id and get list of processors in the group a ProcessorsEntity object. I then step through the list of processors contained in ProcessorsEntity, and for each processor set desired properties contained in  ProcessorEntity and its linked ProcessorDTO and ProcessorConfigDTO classes. I then set ClientId in the Revison object like this:
proc.getRevision().setClientId(restClient.getClientId());
Here proc is ProcessorEntity and restClient is a custom class which contains all code necessary to communicate with NiFi REST API.
At this point I am trying to update the processor through PUT/processors/{id} call, passing it modified data in ProcessorEntity, the same one that I got from ProcessorsEntity and update in place, rather than updating a copy. I figured that there is no need to do it for a DTO object.
When I execute PUT/processors/{id} call, I get an exception, which I need the help with. Here is what I see in Eclipse.
Exception when calling: ProcessorsApi#updateProcessor
Response body: Text '01/01/1970 13:04:02 EST' could not be parsed at index 2 (through reference chain: org.apache.nifi.web.api.entity.ProcessorEntity["status"]->org.apache.nifi.web.api.dto.status.ProcessorStatusDTO["statsLastRefreshed"])
io.swagger.client.ApiException: Bad Request
               at io.swagger.client.ApiClient.handleResponse(ApiClient.java:1058)
               at io.swagger.client.ApiClient.execute(ApiClient.java:981)
               at io.swagger.client.api.ProcessorsApi.updateProcessorWithHttpInfo(ProcessorsApi.java:707)
               at io.swagger.client.api.ProcessorsApi.updateProcessor(ProcessorsApi.java:692)
               at com.bdss.nifi.trickle.NiFiRestClient.updateProcessor(NiFiRestClient.java:149)
               at com.bdss.nifi.trickle.TemplateConfigurator.configureGroupProcessors(TemplateConfigurator.java:84)
               at com.bdss.nifi.trickle.MdmAzureConfigurator.configureGroup(MdmAzureConfigurator.java:89)
               at com.bdss.nifi.trickle.Deployer.deployTemplate(Deployer.java:52)
               at com.bdss.nifi.trickle.Trickle.main(Trickle.java:132)

Notes:
Everything that begins with com.bdss.nifi.trickle are classes in the Java application which I am implementing.
To access NiFi REST API I am using this REST client: https://github.com/simplesteph/nifi-api-client-java, which itself relies on Swagger.

Many thanks for any tips.

STATEMENT OF CONFIDENTIALITY The information contained in this email message and any attachments may be confidential and legally privileged and is intended for the use of the addressee(s) only. If you are not an intended recipient, please: (1) notify me immediately by replying to this message; (2) do not use, disseminate, distribute or reproduce any part of the message or any attachment; and (3) destroy all copies of this message and any attachments.


STATEMENT OF CONFIDENTIALITY The information contained in this email message and any attachments may be confidential and legally privileged and is intended for the use of the addressee(s) only. If you are not an intended recipient, please: (1) notify me immediately by replying to this message; (2) do not use, disseminate, distribute or reproduce any part of the message or any attachment; and (3) destroy all copies of this message and any attachments.

Re: Error when executing NiFi REST API PUT /processors/{id} call

Posted by Daniel Chaffelson <ch...@gmail.com>.
Hi Vitaly,
To give a more detailed example of what Matt is saying, here's the Python
version of what you are doing from the NiPyApi test suite.
In this test we change the scheduling period of a processor to 3s:

processor = nipyapi.canvas.get_processor('someprocessor')
update = nifi.ProcessorConfigDTO(
        scheduling_period='3s'
    )
return nipyapi.nifi.ProcessorsApi().update_processor(
            id=processor.id,
            body=nipyapi.nifi.ProcessorEntity(
                component=nipyapi.nifi.ProcessorDTO(
                    config=update,
                    id=processor.id
                ),
                revision=processor.revision,
            )
        )

I found it very helpful to limit the information passed to the API to
exactly what it needs, as Matt mentioned, to avoid unexpected behaviour.
https://github.com/Chaffelson/nipyapi

Hope this helps,
Dan

On Tue, Mar 13, 2018 at 7:09 PM Matt Gilman <ma...@gmail.com> wrote:

> Vitaly,
>
> I believe that error is being generated by Jackson which handles the JSON
> (de)serialization. Often times there is additional information that gets
> logged to your logs/nifi-user.log. Check there to see if there is anything
> helpful.
>
> By any chance, are you attempting to pass the status back into the update
> call? The entity object holds information about the component (the
> configuration, the revision, status, permissions, etc). When performing an
> update request you only need to pass in the revision (RevisionDTO) and the
> configuration (ProcessorDTO). Check out the Developer Tools in your browser
> to see various requests in action.
>
> Hope this helps.
>
> Matt
>
> On Tue, Mar 13, 2018 at 2:45 PM, Vitaly Krivoy <Vitaly_Krivoy@jhancock.com
> > wrote:
>
>>
>>
>>
>>
>>
>>
>> I am trying to update processors for a workflow, which was previously
>> generated from a template by instantiating it. All work is done from a Java
>> program through NiFi REST API. Template holds processors in a group. Since
>> I know the template group name and strategy by which NiFi assigns a new
>> group name when it instantiates a template (“Copy of “ <original group name
>> in a template>), I find instantiated group by name, get its group id and
>> get list of processors in the group a ProcessorsEntity object. I then
>> step through the list of processors contained in ProcessorsEntity, and
>> for each processor set desired properties contained in  ProcessorEntity and
>> its linked ProcessorDTO and ProcessorConfigDTO classes. I then set ClientId
>> in the Revison object like this:
>> proc.getRevision().setClientId(restClient.getClientId());
>>
>> Here *proc* is ProcessorEntity and restClient is a custom class which
>> contains all code necessary to communicate with NiFi REST API.
>>
>> At this point I am trying to update the processor through
>> PUT/processors/{id} call, passing it modified data in ProcessorEntity, the
>> same one that I got from ProcessorsEntity and update in place, rather
>> than updating a copy. I figured that there is no need to do it for a DTO
>> object.
>> When I execute PUT/processors/{id} call, I get an exception, which I need
>> the help with. Here is what I see in Eclipse.
>>
>> Exception when calling: ProcessorsApi#updateProcessor
>>
>> Response body: Text '01/01/1970 13:04:02 EST' could not be parsed at
>> index 2 (through reference chain:
>> org.apache.nifi.web.api.entity.ProcessorEntity["status"]->org.apache.nifi.web.api.dto.status.ProcessorStatusDTO["statsLastRefreshed"])
>>
>> io.swagger.client.ApiException: Bad Request
>>
>>                at
>> io.swagger.client.ApiClient.handleResponse(ApiClient.java:1058)
>>
>>                at io.swagger.client.ApiClient.execute(ApiClient.java:981)
>>
>>                at
>> io.swagger.client.api.ProcessorsApi.updateProcessorWithHttpInfo(ProcessorsApi.java:707)
>>
>>                at
>> io.swagger.client.api.ProcessorsApi.updateProcessor(ProcessorsApi.java:692)
>>
>>                at
>> com.bdss.nifi.trickle.NiFiRestClient.updateProcessor(NiFiRestClient.java:149)
>>
>>                at
>> com.bdss.nifi.trickle.TemplateConfigurator.configureGroupProcessors(TemplateConfigurator.java:84)
>>
>>                at
>> com.bdss.nifi.trickle.MdmAzureConfigurator.configureGroup(MdmAzureConfigurator.java:89)
>>
>>                at
>> com.bdss.nifi.trickle.Deployer.deployTemplate(Deployer.java:52)
>>
>>                at com.bdss.nifi.trickle.Trickle.main(Trickle.java:132)
>>
>>
>>
>> Notes:
>>
>> Everything that begins with com.bdss.nifi.trickle are classes in the Java
>> application which I am implementing.
>> To access NiFi REST API I am using this REST client:
>> https://github.com/simplesteph/nifi-api-client-java, which itself relies
>> on Swagger.
>>
>>
>>
>> Many thanks for any tips.
>>
>>
>>
>> STATEMENT OF CONFIDENTIALITY The information contained in this email
>> message and any attachments may be confidential and legally privileged and
>> is intended for the use of the addressee(s) only. If you are not an
>> intended recipient, please: (1) notify me immediately by replying to this
>> message; (2) do not use, disseminate, distribute or reproduce any part of
>> the message or any attachment; and (3) destroy all copies of this message
>> and any attachments.
>>
>
>

Re: Error when executing NiFi REST API PUT /processors/{id} call

Posted by Matt Gilman <ma...@gmail.com>.
Vitaly,

I believe that error is being generated by Jackson which handles the JSON
(de)serialization. Often times there is additional information that gets
logged to your logs/nifi-user.log. Check there to see if there is anything
helpful.

By any chance, are you attempting to pass the status back into the update
call? The entity object holds information about the component (the
configuration, the revision, status, permissions, etc). When performing an
update request you only need to pass in the revision (RevisionDTO) and the
configuration (ProcessorDTO). Check out the Developer Tools in your browser
to see various requests in action.

Hope this helps.

Matt

On Tue, Mar 13, 2018 at 2:45 PM, Vitaly Krivoy <Vi...@jhancock.com>
wrote:

>
>
>
>
>
>
> I am trying to update processors for a workflow, which was previously
> generated from a template by instantiating it. All work is done from a Java
> program through NiFi REST API. Template holds processors in a group. Since
> I know the template group name and strategy by which NiFi assigns a new
> group name when it instantiates a template (“Copy of “ <original group name
> in a template>), I find instantiated group by name, get its group id and
> get list of processors in the group a ProcessorsEntity object. I then
> step through the list of processors contained in ProcessorsEntity, and
> for each processor set desired properties contained in  ProcessorEntity and
> its linked ProcessorDTO and ProcessorConfigDTO classes. I then set ClientId
> in the Revison object like this:
> proc.getRevision().setClientId(restClient.getClientId());
>
> Here *proc* is ProcessorEntity and restClient is a custom class which
> contains all code necessary to communicate with NiFi REST API.
>
> At this point I am trying to update the processor through
> PUT/processors/{id} call, passing it modified data in ProcessorEntity, the
> same one that I got from ProcessorsEntity and update in place, rather
> than updating a copy. I figured that there is no need to do it for a DTO
> object.
> When I execute PUT/processors/{id} call, I get an exception, which I need
> the help with. Here is what I see in Eclipse.
>
> Exception when calling: ProcessorsApi#updateProcessor
>
> Response body: Text '01/01/1970 13:04:02 EST' could not be parsed at index
> 2 (through reference chain: org.apache.nifi.web.api.
> entity.ProcessorEntity["status"]->org.apache.nifi.web.api.dto.status.
> ProcessorStatusDTO["statsLastRefreshed"])
>
> io.swagger.client.ApiException: Bad Request
>
>                at io.swagger.client.ApiClient.
> handleResponse(ApiClient.java:1058)
>
>                at io.swagger.client.ApiClient.execute(ApiClient.java:981)
>
>                at io.swagger.client.api.ProcessorsApi.
> updateProcessorWithHttpInfo(ProcessorsApi.java:707)
>
>                at io.swagger.client.api.ProcessorsApi.updateProcessor(
> ProcessorsApi.java:692)
>
>                at com.bdss.nifi.trickle.NiFiRestClient.updateProcessor(
> NiFiRestClient.java:149)
>
>                at com.bdss.nifi.trickle.TemplateConfigurator.
> configureGroupProcessors(TemplateConfigurator.java:84)
>
>                at com.bdss.nifi.trickle.MdmAzureConfigurator.
> configureGroup(MdmAzureConfigurator.java:89)
>
>                at com.bdss.nifi.trickle.Deployer.deployTemplate(
> Deployer.java:52)
>
>                at com.bdss.nifi.trickle.Trickle.main(Trickle.java:132)
>
>
>
> Notes:
>
> Everything that begins with com.bdss.nifi.trickle are classes in the Java
> application which I am implementing.
> To access NiFi REST API I am using this REST client: https://github.com/
> simplesteph/nifi-api-client-java, which itself relies on Swagger.
>
>
>
> Many thanks for any tips.
>
>
>
> STATEMENT OF CONFIDENTIALITY The information contained in this email
> message and any attachments may be confidential and legally privileged and
> is intended for the use of the addressee(s) only. If you are not an
> intended recipient, please: (1) notify me immediately by replying to this
> message; (2) do not use, disseminate, distribute or reproduce any part of
> the message or any attachment; and (3) destroy all copies of this message
> and any attachments.
>