Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Who agreed with this solution

avatar
Master Collaborator

Hi @renuu ,

 

You can use'HandleHttpRequest' to listen for incoming GET/POST request on specific port and respond back using 'HandleHttpResponse' processor.
Add one Http Context Map controller service and use the same in both processor to map request to response, thats it.

Take a look at the below sample configurations.

This HandleHTTPRequest listens for http requests on port 8888 & specifi path i.e /curlRequest.
'Allowed path' is optional, if you just want listen for any request then you ca remove that value.

 

HandleHTTPRequest processorHandleHTTPRequest processor

 

 

HandleHTTPResponse responds to client with 201 response code and any content which is flowfile content.

 

HandleHTTPResponse processorHandleHTTPResponse processor

 

 

 

Instead of curl command I have invoked above listener with another NiFi processor (which you can consider as client)
InvokeHttp processor with target end point as above HandleHTTPRequest host & port.
I am using host as localhost as I am invoking form Nifi (local) only.
For curl command form outside, you need to use your nifi host name instead of 'localhost'.
So that would be 'http://<hostname>':8888/curlRequest

Screenshot 2020-06-03 at 9.45.54 PM.png

 

 

All together - Screenshot 2020-06-03 at 9.49.06 PM.png

 

 

 

Please ACCEPT the solution if it helps/resolves your problem.

 

Thanks

Mahendra

View solution in original post

Who agreed with this solution