【发布时间】:2017-09-28 11:44:55
【问题描述】:
我正在尝试创建一个 REST API 调用以将模板导入到我的 NiFi UI 帖子中,该帖子实例化相同。
下面是我试过的代码,
String siteUrl = "localhost";
String portNumber = "8080";
String pId = "f80896d4-c71f-3395-d527-8c6bd69f44d0";
String pathname = "D:\\Users\\bramasam\\Downloads\\BalaBackUp.xml";
String restString = "http://" + siteUrl + ":" + portNumber + "/nifi-api/process-groups/" + pId + "/templates/upload";
HttpPost httpPost = new HttpPost(restString);
File fileObj = new File(pathname);
httpPost.addHeader("Content-type", "multipart/form-data");
FileEntity fileEntity = new FileEntity(fileObj, ContentType.MULTIPART_FORM_DATA);
httpPost.setEntity(fileEntity);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpResponse response = httpClient.execute(httpPost);
StatusLine status = response.getStatusLine();
System.out.println(status.getStatusCode());
下面是我尝试从中导入的 BalaBackUp.xml 文件中的 {id}
<?xml version="1.0" ?>
<template encoding-version="1.1">
<description></description>
<groupId>bd5dba8b-015d-1000-1fd5-450ede38b7a5</groupId>
<name>BalaBackUp</name>
<snippet>
<processGroups>
<id>f80896d4-c71f-3395-0000-000000000000</id>
<parentGroupId>29a5776d-9728-3fee-0000-000000000000</parentGroupId>
<position>
<x>0.0</x>
<y>0.0</y>
</position>
<comments></comments>
<contents>
<connections>
<id>c0d0e26d-5ee2-3d60-0000-000000000000</id>
<parentGroupId>f80896d4-c71f-3395-0000-000000000000</parentGroupId>
<backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>10000</backPressureObjectThreshold>
<destination>
<groupId>f80896d4-c71f-3395-0000-000000000000</groupId>
<id>1f9e926a-71fc-356f-0000-000000000000</id>
<type>PROCESSOR</type>
我收到 500 的响应代码和以下响应
HttpResponseProxy{HTTP/1.1 500 Internal Server Error [Date: Thu, 28 Sep 2017 09:43:28 GMT, X-Frame-Options: SAMEORIGIN, Content-Type: text/plain, Transfer-Encoding: chunked, Server: Jetty(9.4.3.v20170317)] ResponseEntityProxy{[Content-Type: text/plain,Chunked: true]}}
你能帮我解决我所缺少的吗?
【问题讨论】:
标签: java apache rest apache-nifi