Skip to main content
madhs
Bronze ⭐️⭐️⭐️
June 26, 2023
Question

NiFi InvokeHTTP POST request authenticate via api key and send json input in request body

Hi Team, I require to pass the json created via JoltTranformJSON into the InvokeHTTP call as the body of the rest api post request, require to authenticate the api call via api key (need to send in the header) and need to get the api call response into a variable in Nifi 1.21.0. Can someone please help on this ? 

madhs_2-1687754183966.png

 

madhs_1-1687753731923.png

 

Thank you

4 replies

cjervis
Community Manager
Community Manager
June 26, 2023

Welcome to the community @madhs. @stevenmatison is this something you can provide clarity on?

Translate
Keep the questions coming
joseomjr
Gold ⭐️⭐️
June 26, 2023

Use an UpdateAttribute processor to add attributes with your header values. i.e. Content-Type with value of application/json and in the InvokeHTTP you'll notice there's a field called Attributes to Send (or something like this... They will be the headers) and list those Accept|Authorize|Any other (it's regular expression so you might have to escape some characters). FlowFile content should be sent as the body. 

 

joseomjr_0-1687794448675.png

 

joseomjr_1-1687794491980.png

 

Translate
steven-matison
Platinum ⭐️⭐️
Platinum ⭐️⭐️
June 26, 2023

@madhs @joseomjr A great example of the configuration is above.

 

Here is a full flow definition file/example showing how to get values from JSON and prepare ahead of an InvokeHTTP processor:

 

stevenmatison_0-1687795470750.png

 

Flow Def File:

https://raw.githubusercontent.com/cldr-steven-matison/NiFi-Templates/main/InvokeHttp_Demo_2.json

Translate
cjervis
Community Manager
Community Manager
June 30, 2023

@madhs  Have you resolved your issue. If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. 

 

 

 

Screen Shot 2019-08-06 at 1.54.47 PM.pngmark as solution button

 

 

Translate
Keep the questions coming