从NIFI调用extern REST服务

时间:2017-08-31 08:14:09

标签: apache-nifi

我需要配置一个NIFI流,调用在远程服务器上构建的jenkins。 curl命令可以在我的nifi主机的cmd行中正常工作

curl "http://sktpprdjci01.ccta.dk/jenkins/job/prod-jobs-batch/job/testModel02_batch/buildWithParameters?token=8eabad81fd14bb3f0e8a&model_args=20170829"

我尝试配置NIFI InvokeHTTP处理器,以便在具有以下设置的nifi流中进行调用。

RemoteURL:http://myuser:mypassword@sktpprdjci01.ccta.dk/jenkins/job/prod-jobs-batch/job/testModel02_batch/buildWithParameters?token=8eabad81fd14bb3f0e8a&model_args=20170829
Attributes To Send: Content-Type=application/xml ( have tried with json )
Basic Authentication Username: myuser
Basic Authentication Password: mypassword

但它一直在无重试队列中运行。 我如何根据curl命令配置我的InvokeHTTP工作正常。

curl commando的详细输出

[w20960@sktudv01hdf01 test]$ curl --verbose"http://w19612adm:notrealpassword@sktpprdjci01.ccta.dk/jenkins/job/prod-jobs-batch/job/testModel02_batch/buildWithParameters?token=8eabad81fd14bb3f0e8a&model_args=20170829"
* About to connect() to sktpprdjci01.ccta.dk port 80 (#0)
*   Trying 172.20.242.59...
* Connected to sktpprdjci01.ccta.dk (172.20.242.59) port 80 (#0)
* Server auth using Basic with user 'w19612adm'
> GET /jenkins/job/prod-jobs-batch/job/testModel02_batch/buildWithParameters?token=8eabad81fd14bb3f0e8a&model_args=20170829 HTTP/1.1
> Authorization: Basic dzE5NjEyYWRtOjYyZGUzZjEwODY3ZTgzOTNkOGRmNDdiMTJmY2Y4ODk3
> User-Agent: curl/7.29.0
> Host: sktpprdjci01.ccta.dk
> Accept: */*
>
< HTTP/1.1 201 Created
< Server: nginx/1.10.2
< Date: Thu, 31 Aug 2017 09:39:13 GMT
< Content-Length: 0
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< Location: http://sktpprdjci01.ccta.dk/jenkins/queue/item/2601/
<
* Connection #0 to host sktpprdjci01.ccta.dk left intact
[w20960@sktudv01hdf01 test]$

No Retry关系中的流文件的属性

model_args    20170829
invokehttp.tx.id   f1f3074e-007c-40e4-8e1d-4ef7c4ea7f62
file.group    nifi
file.lastModifiedTime 2017-08-29T13:58:12+0200
invokehttp.status.code 407
invokehttp.response.body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content- Type" content="text/html; charset=UTF-8"> <title>Notification: Proxy   Authorization Required</title> <style type="
file.permissions rwxrwxrwx
uuid e6d95b8d-5385-4463-98cf-2982734d1bc4
token 8eabad81fd14bb3f0e8a
 absolute.pat /opt/nifi/ekapital/ek_abt/
invokehttp.request.url http://ktpprdjci01.ccta.dk/jenkins/job/prod-jobs-batch/job/testModel02_batch/buildWithParameters?token=8eabad81fd14bb3f0e8a&model_args=20170829
path /
filename ek_abt.hql
file.creationTime 2017-08-29T13:58:12+0200
file.lastAccessTime 2017-08-30T14:03:15+0200
file.owner nifi
invokehttp.status.message Proxy Authentication Required
OK

1 个答案:

答案 0 :(得分:2)

所以你有回应:

invokehttp.status.code    : 407
invokehttp.status.message : Proxy Authentication Required

似乎您正在使用需要身份验证的代理

重复curl中的问题尝试使用--noproxy参数或取消设置代理配置。

然后尝试了解您必须传递哪些参数/标题才能访问您的网址。

PS:对我来说很好:

enter image description here

url: http://localhost:8081/job/test01/buildWithParameters?token=12345&P1=aaabbbccc

不要忘记在jenkins作业中选择Trigger builds remotely复选框

相关问题