In NiFi processor 'InvokeHTTP' where do you write body of POST request?

こ雲淡風輕ζ 提交于 2019-12-22 09:37:48

问题


Before posting this question about Apache NiFi InvokeHTTP I have gone through all other questions and their answersbut I am still unsure the best flow I should have. My situation is as below:

1) From Apache Kakfa, I get raw metadata.

2) Using EvaluateJSONPath I get attribute I want.

3) Using RouteOnAttribute I created 3 routes based on the attribute value I got from step-2 above.

4) Now based on the attribute value I want to decide whether I should go for GET or for POST or for Delete.

5) My question is where/how to set POST message? GET message? Delete Message body?

6) I am able to set the URL in configuration part provided by InvokeHTTP. But message body I don't know which is that property? or its in flow file using ReplaceText?

I read somewhere that before you divert your Restful POST HTTP request to InvokeHTTP you must have another processor before which changes the content of flow file.

Ref: Configuring HTTP POST request from Nifi

Please help. Thanks. regards, Yeshwant


回答1:


Adding on to what Bryan had explained, POST will use the FlowFile content as the message body so if you have some other data which you want to wipe/transform into something and then sent as the message body, you can leverage the following processors :

  • ExtractText to read data from the existing FlowFile content
  • ReplaceText to erase the existing content of the FlowFile and replace it with different one

To set the headers for the REST calls, InvokeHTTP has the property Attributes to Send property which takes a regex which will scanned against the incoming FlowFiles' attributes and whichever attributes are matched are taken and sent as HTTP header.

To add new attribute to your existing FlowFile, you can use UpdateAttribute




回答2:


For a POST, the body will be whatever is in the flow file content.

a GET and DELETE typically wouldn't have a body since the information would typically be provided in the URL or query params.



来源:https://stackoverflow.com/questions/53831579/in-nifi-processor-invokehttp-where-do-you-write-body-of-post-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!