Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nifi invokehttp post complex json

I trying to use InvokeHttpProcessor in Apache NiFi to perform POST request with complex JSON body. Accordingly this tutorial: http://www.tomaszezula.com/2016/10/30/nifi-and-http-post-configuration

I know how to use UpdateAttribute processor to add name/value pairs and then apply an additional transformation via AttributesToJSON.

But how to deal with complex JSON? For example I have to perform request to GoogleAnalytics reporting API, so I need to perform this request:

POST https://analyticsreporting.googleapis.com/v4/reports:batchGet

{
  "reportRequests":
  [
    {
      "viewId": "XXXX",
      "dateRanges": [{"startDate": "2014-11-01", "endDate": "2014-11-30"}],
      "metrics": [{"expression": "ga:users"}]
    }
  ]
}

any ideas?

like image 756
Bo. Avatar asked Mar 10 '23 12:03

Bo.


1 Answers

You can use the GenerateFlowFile and ReplaceText processors to provide a template as the flowfile content and then populate the actual values. Once that JSON object is formed as flowfile content, it should be easy to send it via POST using InvokeHTTP

like image 99
Andy Avatar answered Mar 12 '23 02:03

Andy