- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Nifi InvokeHTTP to get a token from an API
- Labels:
-
Apache NiFi
Created 06-01-2018 04:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have curl command as below.
curl -s -XPOST -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d 'username=usco&password=asdl2342&client_id=dwer234324-2sd2-32dwq&scope=read' 'https://rest.abc.com/security'
I am trying to replicate this in Nifi. I am trying to figure out how and where the above options to be provided in InvokeHTTP processor. I have gone through the articles and some mentioned I have to define it in body of flow file. But I couldn't understand what exactly goes into body and what goes into extra attributes (if I need to add) in InvokeHTTP processsor.
Created 06-01-2018 05:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is what I think you should use to make this work:
-X POST | use processor HTTP method attribute and set to POST |
-x http://proxyhost:port | I think you should consider adding this configuration or add properties Proxy host=proxyhost, Proxy port=port and Proxy protocol=https |
-H "Accept: application/json" | Use the Attributes to send referencing a new attribute with the value (add 1 extra attributes with corresponding value) |
-H "Content-Type: application/x-www-form-urlencoded" | Use Content type attribute |
-d 'data sent' | Send Message Body = true. And the content should come as inbound flowfile to the processor. To test try adding a GenerateFlowFile processor with the content without single quotes |
https://hostname/security/v1/oauth/token | Set in Remote url |
Finally since endpoint is ssl enabled you need to set SSL Context Service.
HTH
*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
Created 06-01-2018 05:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is what I think you should use to make this work:
-X POST | use processor HTTP method attribute and set to POST |
-x http://proxyhost:port | I think you should consider adding this configuration or add properties Proxy host=proxyhost, Proxy port=port and Proxy protocol=https |
-H "Accept: application/json" | Use the Attributes to send referencing a new attribute with the value (add 1 extra attributes with corresponding value) |
-H "Content-Type: application/x-www-form-urlencoded" | Use Content type attribute |
-d 'data sent' | Send Message Body = true. And the content should come as inbound flowfile to the processor. To test try adding a GenerateFlowFile processor with the content without single quotes |
https://hostname/security/v1/oauth/token | Set in Remote url |
Finally since endpoint is ssl enabled you need to set SSL Context Service.
HTH
*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
Created 04-19-2020 11:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached is the screenshot for the solution
E2E Flow
Generate Flow File
InvokeHttp.
Created 06-04-2018 02:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much. that worked perfectly. I have one more question. What if I have one more header such as -H "Authorization: Bearer 27ffdfada34982-1123qwdq2" . How do I send it ?
Should I be adding one more property and set the name as 'Authorization and Value as Bearer 27ffdfada34982-1123qwdq2 ?
or
Can I specify more than one attribute in AttributestoSend in InvokeHTTP processor ? If yes, should they be seperated by comma or space or something else ?
Created 06-04-2018 02:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@RC Based on the documentation is a regular expression:
Regular expression that defines which attributes to send as HTTP headers in the request.
perhaps you can name your list of attributes:
httpheader1<br>httpheader2<br>httpheaderN
then use a regex like this httpheader[1-N]
HTH
Created 06-07-2018 05:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have added Accept and Authorization in UpdateAttribute processor before InovkeHTTP processor and in the Attributes to Send property (in InovkeHTTP) - I have used .*
Created 05-17-2022 02:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @karteek_chunchu
I am also working on Authorization: Bearer, Could you please me know how you added this token in invoke HTTP processor.
if you have a sample template, what are the configurations needed for this, can you please let me know.
Thanks,
Venkat
Created 05-17-2022 02:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Venkatgundla Hi, as this is an older post, you would have a better chance of receiving a resolution by starting a new thread. This will also be an opportunity to provide details specific to your environment that could aid others in assisting you with a more accurate answer to your question. You can link this thread as a reference in your new post. Thanks!
Regards,
Diana Torres,Community Moderator
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
Created 06-06-2022 06:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created 06-06-2022 06:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are looking to authenticate using Oath2.0 then you need to create new property in the InvokeHttp processor and call the property "Authorization" and the value should be set as:
"Bearer [Authorization Token]". First you need to get the authentication token. hope that helps.
