nifi invokehttp发布复杂的json [英] nifi invokehttp post complex json

查看:237
本文介绍了nifi invokehttp发布复杂的json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Apache NiFi中使用InvokeHttpProcessor来执行具有复杂JSON正文的POST请求. 因此,本教程如下: http://www.tomaszezula. com/2016/10/30/nifi-and-http-post-configuration

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

我知道如何使用 UpdateAttribute 处理器添加名称/值对,然后通过 AttributesToJSON 应用其他转换.

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

但是如何处理复杂的JSON? 例如,我必须执行对GoogleAnalytics报表API的请求,因此我需要执行以下请求:

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"}]
    }
  ]
}

有什么想法吗?

推荐答案

您可以使用GenerateFlowFileReplaceText处理器提供模板作为流文件内容,然后填充实际值.一旦将该JSON对象形成为流文件内容,就应该很容易使用InvokeHTTP

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

这篇关于nifi invokehttp发布复杂的json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆