Support Questions

Find answers, ask questions, and share your expertise

Nifi PostHTTP response data

avatar
Contributor

I've successfully created a process in Nifi to send a POST to a web service, but i'm unable to find out how to incorporate the post response into the httpresponse for the caller. Does anyone know if this is possible or did I go the wrong route for a post/modify/response service?

EDIT:

the flow I have is:

HandleHttpRequest --> PutFile --> PostHTTP --> ReplaceText --> PutFile --> HandleHttpResponse

the only thing that seems to apply a change to the text is the ReplaceText being submitted. The first PutFile contains the text submitted, the second PutFile only contains the text modified by the replacetext. the PostHTTP result does not seem to be incorporated into the result.

1 ACCEPTED SOLUTION

avatar

Hi @Christopher Amatulli,

Once your FlowFile is created when receiving your request, you make it goes your flow and change the content of your flow file with what you want to return to the user. Then you route this FlowFile to the response processor and you set the HTTP return code you want. The response body will be the content of your flow file.

Hope this helps.

View solution in original post

7 REPLIES 7

avatar

Hi @Christopher Amatulli,

Once your FlowFile is created when receiving your request, you make it goes your flow and change the content of your flow file with what you want to return to the user. Then you route this FlowFile to the response processor and you set the HTTP return code you want. The response body will be the content of your flow file.

Hope this helps.

avatar
Contributor

That's not what is happening or at least it's not working that way in my setup. The flow I have is:

HandleHttpRequest --> PutFile --> PostHTTP --> ReplaceText --> PutFile --> HandleHttpResponse

the only thing that seems to apply a change to the text is the ReplaceText being submitted. The first PutFile contains the text submitted, the second PutFile only contains the text modified by the replacetext. the PostHTTP result does not seem to be incorporated into the result.

avatar

If possible, could you share your template, I'll have a quick look at it.

Is it the same flow file from one end to another? When putting your file on disk before the response processor does it have the content you are expecting? What are the properties in your response processor?

avatar
Contributor

attached, thanks. I can trace the PostHTTP, and I see the response from the post. but the text doesn't seem to make it through to the replacetext or the second putfile.

avatar

Oh... looking at your template, I think I realized I misunderstood you. Your problem is that the answer of the PostHTTP is not getting inside the content of the FlowFile and the consequence is that it won't make through to the HTTP response processor. Correct?

If yes, it is because PostHTTP is a legacy processor and the response of the request won't be written to the flow file content. Instead I recommend you using InvokeHTTP which a more recent processor with a lot of options and you will have a relationship for HTTP responses of your POST request.

Let me know if it is ok.

avatar
Contributor

InvokeHTTP looks to have gotten me closer, only issue now is I am only getting the Post response, the original text is stripped. Thanks, this solves my original problem though.

avatar
New Contributor

Try using SELECTHIVEQL processor for your hive connection and Hive query instead of ExecuteSQL or QueryDatabase