You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Chakrader Dewaragatla <Ch...@lifelock.com> on 2015/11/05 01:14:59 UTC

Rest API for templates.

Hi -  I was looking at the REST apis to create, manage templates. Looks like import template is not implemented, correct me if I am wrong ? It is not documented in API guide.

Thanks,
-Chakri

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

Re: Rest API for templates.

Posted by Chakrader Dewaragatla <Ch...@lifelock.com>.
Thanks Matt, it works.
Appreciate your help.

From: Matt Gilman <ma...@gmail.com>>
Reply-To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Date: Tuesday, December 1, 2015 at 4:28 PM
To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Subject: Re: Rest API for templates.

Chakrader,

I was able to upload using curl with the follow command.

curl -X POST -v -F template=@"/path/to/template.xml" http://{host}:{port}/nifi-api/controller/templates

The endpoint that accepts the template upload accepts multipart/form-data which I believe is the default when using curl with -F. Also the form parameter that accepts the template is named "template".

Let me know if your still experencing any issues. Thanks!

Matt

On Tue, Dec 1, 2015 at 6:38 PM, Chakrader Dewaragatla <Ch...@lifelock.com>> wrote:
Matt – Thanks for reply and sorry for delay in trying out.
I have problem importing and errors as “template is not in a valid format”

Here is the curl command and output of the import template command.


% curl -X POST -H"ContentType:text/xml" -H"Accept:application/xml" http://localhost:9080/nifi-api/controller/templates -F"name=template" -F”filename=template_request.xml"  -F"upload=@./template_request.xml" -v

*   Trying ::1...

* connect to ::1 port 9080 failed: Connection refused

*   Trying 127.0.0.1...

* Connected to localhost (127.0.0.1) port 9080 (#0)

> POST /nifi-api/controller/templates HTTP/1.1

> Host: localhost:9080

> User-Agent: curl/7.43.0

> ContentType:text/xml; Content-Disposition: form-data;

> Accept:application/xml

> Content-Length: 11377

> Expect: 100-continue

> Content-Type: multipart/form-data; boundary=------------------------51d5291195f283d6

>

< HTTP/1.1 100 Continue

< HTTP/1.1 200 OK

< Date: Tue, 01 Dec 2015 22:34:41 GMT

< Content-Type: application/xml

< Vary: Accept-Encoding, User-Agent

< Transfer-Encoding: chunked

< Server: Jetty(9.2.11.v20150529)

<

* Connection #0 to host localhost left intact

<errorResponse status="400" statusText="The specified template is not in a valid format.”/>



From: Matt Gilman <ma...@gmail.com>>
Reply-To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Date: Wednesday, November 4, 2015 at 5:12 PM
To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Subject: Re: Rest API for templates.

Chakri,

The endpoint exists but due to a shortcoming in the documentation tool it does not get included. There are two different options for importing a template. Both are located at

POST https://{host}:{port}/nifi-api/controller/templates

You can invoke this endpoint three different ways. The way that gets included in the documentation creates a new template based off a snippet identifier. This allows you to create a template based off a snippet of your local flow.

The other two ways allow you to create a template based off of an existing one:
- One option is to send a request with multi-part form data (file upload - this is what the UI does). The form parameter of the template is named "template".
- The next option would be to include the serialized template in the body of the request. Specifically, this is serialized as a TemplateEntity which is the same as the response of the first request I mentioned above (an example of this is in the documentation). This version of the endpoint accepts application/xml or application/json.

I've received this question a couple times so I've created a JIRA for addressing it. [1]

Matt

[1] https://issues.apache.org/jira/browse/NIFI-1113

On Wed, Nov 4, 2015 at 7:14 PM, Chakrader Dewaragatla <Ch...@lifelock.com>> wrote:
Hi -  I was looking at the REST apis to create, manage templates. Looks like import template is not implemented, correct me if I am wrong ? It is not documented in API guide.

Thanks,
-Chakri

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

Re: Rest API for templates.

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

I was able to upload using curl with the follow command.

curl -X POST -v -F template=@"/path/to/template.xml" http://
{host}:{port}/nifi-api/controller/templates

The endpoint that accepts the template upload accepts multipart/form-data
which I believe is the default when using curl with -F. Also the form
parameter that accepts the template is named "template".

Let me know if your still experencing any issues. Thanks!

Matt

On Tue, Dec 1, 2015 at 6:38 PM, Chakrader Dewaragatla <
Chakrader.Dewaragatla@lifelock.com> wrote:

> Matt – Thanks for reply and sorry for delay in trying out.
> I have problem importing and errors as “template is not in a valid format”
>
> Here is the curl command and output of the import template command.
>
>
> *% curl -X POST -H"ContentType:text/xml"
> -H"Accept:application/xml" http://localhost:9080/nifi-api/controller/templates
> <http://localhost:9080/nifi-api/controller/templates> -F"name=template"
> -F”filename=template_request.xml"  -F"upload=@./template_request.xml" -v*
>
> **   Trying ::1...*
>
> ** connect to ::1 port 9080 failed: Connection refused*
>
> **   Trying 127.0.0.1...*
>
> ** Connected to localhost (127.0.0.1) port 9080 (#0)*
>
> *> POST /nifi-api/controller/templates HTTP/1.1*
>
> *> Host: localhost:9080*
>
> *> User-Agent: curl/7.43.0*
>
> *> ContentType:text/xml; Content-Disposition: form-data;*
>
> *> Accept:application/xml*
>
> *> Content-Length: 11377*
>
> *> Expect: 100-continue*
>
> *> Content-Type: multipart/form-data;
> boundary=------------------------51d5291195f283d6*
>
> *> *
>
> *< HTTP/1.1 100 Continue*
>
> *< HTTP/1.1 200 OK*
>
> *< Date: Tue, 01 Dec 2015 22:34:41 GMT*
>
> *< Content-Type: application/xml*
>
> *< Vary: Accept-Encoding, User-Agent*
>
> *< Transfer-Encoding: chunked*
>
> *< Server: Jetty(9.2.11.v20150529)*
>
> *< *
>
> ** Connection #0 to host localhost left intact*
>
> *<errorResponse status="400" statusText="The specified template is not in
> a valid format.”/>*
>
>
>
>
> From: Matt Gilman <ma...@gmail.com>
> Reply-To: "users@nifi.apache.org" <us...@nifi.apache.org>
> Date: Wednesday, November 4, 2015 at 5:12 PM
> To: "users@nifi.apache.org" <us...@nifi.apache.org>
> Subject: Re: Rest API for templates.
>
> Chakri,
>
> The endpoint exists but due to a shortcoming in the documentation tool it
> does not get included. There are two different options for importing a
> template. Both are located at
>
> POST https://{host}:{port}/nifi-api/controller/templates
>
> You can invoke this endpoint three different ways. The way that gets
> included in the documentation creates a new template based off a snippet
> identifier. This allows you to create a template based off a snippet of
> your local flow.
>
> The other two ways allow you to create a template based off of an existing
> one:
> - One option is to send a request with multi-part form data (file upload -
> this is what the UI does). The form parameter of the template is named
> "template".
> - The next option would be to include the serialized template in the body
> of the request. Specifically, this is serialized as a TemplateEntity which
> is the same as the response of the first request I mentioned above (an
> example of this is in the documentation). This version of the endpoint
> accepts application/xml or application/json.
>
> I've received this question a couple times so I've created a JIRA for
> addressing it. [1]
>
> Matt
>
> [1] https://issues.apache.org/jira/browse/NIFI-1113
>
> On Wed, Nov 4, 2015 at 7:14 PM, Chakrader Dewaragatla <
> Chakrader.Dewaragatla@lifelock.com> wrote:
>
>> Hi -  I was looking at the REST apis to create, manage templates. Looks
>> like import template is not implemented, correct me if I am wrong ? It is
>> not documented in API guide.
>>
>> Thanks,
>> -Chakri
>>
>> ------------------------------
>> The information contained in this transmission may contain privileged and
>> confidential information. It is intended only for the use of the person(s)
>> named above. If you are not the intended recipient, you are hereby notified
>> that any review, dissemination, distribution or duplication of this
>> communication is strictly prohibited. If you are not the intended
>> recipient, please contact the sender by reply email and destroy all copies
>> of the original message.
>> ------------------------------
>>
>
> ------------------------------
> The information contained in this transmission may contain privileged and
> confidential information. It is intended only for the use of the person(s)
> named above. If you are not the intended recipient, you are hereby notified
> that any review, dissemination, distribution or duplication of this
> communication is strictly prohibited. If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message.
> ------------------------------
>

Re: Rest API for templates.

Posted by Chakrader Dewaragatla <Ch...@lifelock.com>.
Matt – Thanks for reply and sorry for delay in trying out.
I have problem importing and errors as “template is not in a valid format”

Here is the curl command and output of the import template command.


% curl -X POST -H"ContentType:text/xml" -H"Accept:application/xml" http://localhost:9080/nifi-api/controller/templates -F"name=template" -F”filename=template_request.xml"  -F"upload=@./template_request.xml" -v

*   Trying ::1...

* connect to ::1 port 9080 failed: Connection refused

*   Trying 127.0.0.1...

* Connected to localhost (127.0.0.1) port 9080 (#0)

> POST /nifi-api/controller/templates HTTP/1.1

> Host: localhost:9080

> User-Agent: curl/7.43.0

> ContentType:text/xml; Content-Disposition: form-data;

> Accept:application/xml

> Content-Length: 11377

> Expect: 100-continue

> Content-Type: multipart/form-data; boundary=------------------------51d5291195f283d6

>

< HTTP/1.1 100 Continue

< HTTP/1.1 200 OK

< Date: Tue, 01 Dec 2015 22:34:41 GMT

< Content-Type: application/xml

< Vary: Accept-Encoding, User-Agent

< Transfer-Encoding: chunked

< Server: Jetty(9.2.11.v20150529)

<

* Connection #0 to host localhost left intact

<errorResponse status="400" statusText="The specified template is not in a valid format.”/>



From: Matt Gilman <ma...@gmail.com>>
Reply-To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Date: Wednesday, November 4, 2015 at 5:12 PM
To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Subject: Re: Rest API for templates.

Chakri,

The endpoint exists but due to a shortcoming in the documentation tool it does not get included. There are two different options for importing a template. Both are located at

POST https://{host}:{port}/nifi-api/controller/templates

You can invoke this endpoint three different ways. The way that gets included in the documentation creates a new template based off a snippet identifier. This allows you to create a template based off a snippet of your local flow.

The other two ways allow you to create a template based off of an existing one:
- One option is to send a request with multi-part form data (file upload - this is what the UI does). The form parameter of the template is named "template".
- The next option would be to include the serialized template in the body of the request. Specifically, this is serialized as a TemplateEntity which is the same as the response of the first request I mentioned above (an example of this is in the documentation). This version of the endpoint accepts application/xml or application/json.

I've received this question a couple times so I've created a JIRA for addressing it. [1]

Matt

[1] https://issues.apache.org/jira/browse/NIFI-1113

On Wed, Nov 4, 2015 at 7:14 PM, Chakrader Dewaragatla <Ch...@lifelock.com>> wrote:
Hi -  I was looking at the REST apis to create, manage templates. Looks like import template is not implemented, correct me if I am wrong ? It is not documented in API guide.

Thanks,
-Chakri

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

________________________________
The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
________________________________

Re: Rest API for templates.

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

The endpoint exists but due to a shortcoming in the documentation tool it
does not get included. There are two different options for importing a
template. Both are located at

POST https://{host}:{port}/nifi-api/controller/templates

You can invoke this endpoint three different ways. The way that gets
included in the documentation creates a new template based off a snippet
identifier. This allows you to create a template based off a snippet of
your local flow.

The other two ways allow you to create a template based off of an existing
one:
- One option is to send a request with multi-part form data (file upload -
this is what the UI does). The form parameter of the template is named
"template".
- The next option would be to include the serialized template in the body
of the request. Specifically, this is serialized as a TemplateEntity which
is the same as the response of the first request I mentioned above (an
example of this is in the documentation). This version of the endpoint
accepts application/xml or application/json.

I've received this question a couple times so I've created a JIRA for
addressing it. [1]

Matt

[1] https://issues.apache.org/jira/browse/NIFI-1113

On Wed, Nov 4, 2015 at 7:14 PM, Chakrader Dewaragatla <
Chakrader.Dewaragatla@lifelock.com> wrote:

> Hi -  I was looking at the REST apis to create, manage templates. Looks
> like import template is not implemented, correct me if I am wrong ? It is
> not documented in API guide.
>
> Thanks,
> -Chakri
>
> ------------------------------
> The information contained in this transmission may contain privileged and
> confidential information. It is intended only for the use of the person(s)
> named above. If you are not the intended recipient, you are hereby notified
> that any review, dissemination, distribution or duplication of this
> communication is strictly prohibited. If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message.
> ------------------------------
>