Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

NiFi: InvokeHTTP dynamic headers from attributes

avatar
New Contributor

Hi, been stuck with this for a while now and for the life of me i cant seem to figure it out. 

 

we have a flow file that has a set of headers that needs to be attached to the invokehttp processor. we dont know what those headers might be beforehand so cant do the + add property thing. 

 

the headers are attributes on the flow file with a "headers." prefix (this can be changed)

 

the flow of the entire workflow is

  1. json content with object of headers to set
  2. HandleHTTPRequest to start the nifi flow
  3. some stuff
  4. script to take the $.item.headers and turn it into attributes with a prefix "headers."
  5. InvokeHTTP

the initial json looks a bit like this

 

 

 

 

{
    "method": "POST",
    "item": {
        "id": 100,
        "headers": {
            "Content-Length": "520",
            "Content-Type": "multipart/form-data; boundary=--------------------------989211997649303340983260",
            "Connection": "keep-alive",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept": "*/*",
            "User-Agent": "PostmanRuntime/7.29.2",
        },
        "status": "PENDING"
    },

}   

 

 

 

. (please note that we dont know what the headers might be. they could include a bunch more)

 

the invokehttp needs to include all these headers

 

each of the headers is added as an attribute by the flow

AwStam_0-1664801026006.png

 

on the InvokeHTTP processor

AwStam_1-1664801090865.png

 

 

what ive tried for "Attributes to send": 

  • headers
  • headers.
  • headers.*
  • (?<=headers.).* 

(the last 1 is since its regex 

 

AwStam_3-1664801184519.png

 

  • is there a way to add headers to the flow file before it gets to the InvokeHTTP (like say a ExecuteScript)
  • is there a way to do " headers.* " to the "attributes to send" (headers.X-INSTANCE, headers.Content-Type, headers.SomethingElse)
  • is there a way to have a single "headers" attribute with json (so naturally a string of json cause nifi) merge with the invokehttp headers and replace those that exist

on the nifi 1.11.4 (for now)

0 REPLIES 0