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

查看:68
本文介绍了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 对象形成为流文件内容,就应该很容易通过 POST 使用 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天全站免登陆