havmaage
havmaage

Reputation: 613

Calling extern REST Service from NIFI

I need to configure a NIFI flow thats invoke a jenkins built on a remote server. The curl command works fine from the cmd line of my nifi host

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

Im trying to configure NIFI InvokeHTTP processor to make the call from within a nifi flow with following settings.

RemoteURL:http://myuser:[email protected]/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

But it keeps running in the no retry queue. how do i configure my InvokeHTTP according to the curl command which works ok.

verbose output of curl commando

[w20960@sktudv01hdf01 test]$ curl --verbose"http://w19612adm:[email protected]/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]$

Attrributes on flowfile in No Retry relation

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

Upvotes: 0

Views: 1210

Answers (1)

daggett
daggett

Reputation: 28634

so you have in response:

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

seems you are working through proxy that requires authentication

to repeat the problem in curl try to use --noproxy parameter or unset proxy configuration.

then try to understand what parameters/headers you have to pass to access your url.

PS: works fine for me:

enter image description here

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

don't forget to select in jenkins job Trigger builds remotely checkbox

Upvotes: 1

Related Questions