You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by "BOUKRAA, Kacem" <bk...@esi.dz> on 2016/01/02 12:40:32 UTC

How to extract attributes from ListenHTTP flow file?

Hello.

So, i'm using ListenHTTP processor to listen to some POST requests comping
from a push notification service.

I'm receiving something like this:

​now, i want to use something to set the post attribute entry as a fiow
attribute ($_POST["entry"]).
the ListenHTTP has this attribute:
Is that helpful to se file attributes? can i have an example of the syntax
to use in my case. is it only: entry? or i should use another syntax.

Thanks in advance
​

Re: How to extract attributes from ListenHTTP flow file?

Posted by "BOUKRAA, Kacem" <bk...@esi.dz>.
Simon, i really thank you for your help.

I was able to add an intermediate parser to convert post request to a Body
as you suggested, now everything is working fine. So no need to add
internal processor (since it's more complicated then a simple PHP proxy).

Thanks again.

On 2 January 2016 at 13:04, Simon Ball <sb...@hortonworks.com> wrote:

> It looks like what you have there is a JSON object inside a form encoded
> POST body, which is a little unusual. The header extraction won’t help you,
> since you’re looking to extract from the body, not the header. At the
> moment, nifi doesn’t handle the double encoding, but what you could do is
> either:
>
> a. fix the posting API so it sends JSON as the body, without the form
> encoding, and then use EvaluateJsonPath.
> b. use ExtractText to pull the entry content out of the body into an
> attribute for further processing.
> c. use SplitContent to turn the incoming POSTs into FlowFiles just
> containing the JSON piece, a slightly less efficient version of this might
> also be possible with ReplaceText, if the split strings prove hard to
> define given any other unspecified content.
> d. Write a custom processor which pulls out form-encoded POSTs to
> attributes.
>
> Option a is more likely to be useful to you down the line, since I’m
> guessing you’ll want to do things like EvaluateJsonPath on the content of
> the entry object for different routing for example. A hybrid of b and a is
> also possible through c.
>
> Hope that helps,
> Simon
>
> On 2 Jan 2016, at 11:40, BOUKRAA, Kacem <bk...@esi.dz> wrote:
>
> Hello.
>
> So, i'm using ListenHTTP processor to listen to some POST requests comping
> from a push notification service.
>
> I'm receiving something like this:
> <Screen Shot 2016-01-02 at 12.36.41 PM.png>
> ​now, i want to use something to set the post attribute entry as a fiow
> attribute ($_POST["entry"]).
> the ListenHTTP has this attribute:
> <Screen Shot 2016-01-02 at 12.36.47 PM.png>
> Is that helpful to se file attributes? can i have an example of the syntax
> to use in my case. is it only: entry? or i should use another syntax.
>
> Thanks in advance
> ​
>
>
>


-- 

[image: Image]

*Kacem BOUKRAA**5**th**year student at ESI | Higher National School Of
Computer Science** (Information Systems)*
*Google Student Ambassador in Algeria*

*Kouba - Alger*
*mobile: +213 559 859 858 |  **email: me@kacemb.com <me...@kacemb.com>*
*twitter: @kacem4dz |  website: www.kacemb.com <http://www.kacemb.com>*
  <https://www.facebook.com/KacemRostomBoukraa>
<https://plus.google.com/u/0/+KacemBOUKRAA>
<https://www.linkedin.com/profile/view?id=177866682>
<https://twitter.com/kacem4dz>

Re: How to extract attributes from ListenHTTP flow file?

Posted by Simon Ball <sb...@hortonworks.com>.
It looks like what you have there is a JSON object inside a form encoded POST body, which is a little unusual. The header extraction won’t help you, since you’re looking to extract from the body, not the header. At the moment, nifi doesn’t handle the double encoding, but what you could do is either:

a. fix the posting API so it sends JSON as the body, without the form encoding, and then use EvaluateJsonPath.
b. use ExtractText to pull the entry content out of the body into an attribute for further processing.
c. use SplitContent to turn the incoming POSTs into FlowFiles just containing the JSON piece, a slightly less efficient version of this might also be possible with ReplaceText, if the split strings prove hard to define given any other unspecified content.
d. Write a custom processor which pulls out form-encoded POSTs to attributes.

Option a is more likely to be useful to you down the line, since I’m guessing you’ll want to do things like EvaluateJsonPath on the content of the entry object for different routing for example. A hybrid of b and a is also possible through c.

Hope that helps,
Simon

On 2 Jan 2016, at 11:40, BOUKRAA, Kacem <bk...@esi.dz>> wrote:

Hello.

So, i'm using ListenHTTP processor to listen to some POST requests comping from a push notification service.

I'm receiving something like this:
<Screen Shot 2016-01-02 at 12.36.41 PM.png>
​now, i want to use something to set the post attribute entry as a fiow attribute ($_POST["entry"]).
the ListenHTTP has this attribute:
<Screen Shot 2016-01-02 at 12.36.47 PM.png>
Is that helpful to se file attributes? can i have an example of the syntax to use in my case. is it only: entry? or i should use another syntax.

Thanks in advance
​