Support Questions

Find answers, ask questions, and share your expertise

Use InvokeHTTP response body in another InvokeHTTP

avatar
New Contributor

Hi there,

sorry for my silly question.

 

I have a InvokeHTTP processor which returns plaintext access token in the response body, since it is larger than 256 bytes I cannot assign it to an attribute. I need to use the token in another InvokeHTTP as a header to retrieve data. Token is a plain text (not a json).

 

Thanks!

1 ACCEPTED SOLUTION

avatar

Hi,

 

If you're using Apache NiFi and the token you're trying to capture with the InvokeHTTP processor is too large to be stored as an attribute, you can follow the steps below to work around this limitation:

 

Keep the token in the content of the FlowFile if it's returned by the InvokeHTTP processor.

 

You can use processors like ReplaceText to wrap the token in the header format you need. For instance, if you need the header to be Authorization: Bearer {token}, then you can configure a ReplaceText processor to replace the content (i.e., the token) to match this format.

View solution in original post

6 REPLIES 6

avatar
Community Manager

@leqlaz777 Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our NiFi experts @SAMSAL @cotopaul  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.


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:

avatar
Super Guru

How are you authenticating? Are you using OAuth2 token for example? If so see if you can take advantage of the "OAuth2 Access Token provider" in the InvokeHttp processors where you set and configure your token provider as a service:

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-oauth2-provider-nar/1.22.0/or...

 

If that helps please accept solution.

Thanks

 

avatar
New Contributor

Hi,

Not exactly oAuth2, I send Authorization: Bearer [API KEY] header to /auth endpoint via POST request and get a JWT access token. Which then I have to use as an auth header to access resources.

In StandardOauth2AccessTokenProvider I am not able to use simple Bearer token in header.

avatar
Master Mentor

@leqlaz777 
What version of NiFi are you using?
How large is your response body?

I have no issues creating FlowFile Attributes with values larger then 256 bytes.
Can you share your processors being used and the configuration of them?

Thank you,

Matt

avatar
New Contributor

Hi,

My version is 1.20.

It is a JWT token between 400-500 bytes.

I missed "Response Body Attribute Size" parameter, I can set arbitrary size to attribute. After changing it I am able to pass full length of my token.

avatar

Hi,

 

If you're using Apache NiFi and the token you're trying to capture with the InvokeHTTP processor is too large to be stored as an attribute, you can follow the steps below to work around this limitation:

 

Keep the token in the content of the FlowFile if it's returned by the InvokeHTTP processor.

 

You can use processors like ReplaceText to wrap the token in the header format you need. For instance, if you need the header to be Authorization: Bearer {token}, then you can configure a ReplaceText processor to replace the content (i.e., the token) to match this format.