Support Questions
Find answers, ask questions, and share your expertise

[NIFI] Is it possible to make a x-www-form-urlencoded POST request through InvokeHttp

Explorer

Hi, 

I just started using Nifi and i would like to know if it's possible to perform a POST with a content-type set to `x-www-form-urlencoded`. I need to pass these key/values to my request : 

 

grant_type	refresh_token
client_id	myClientId
client_secret	myClientSecret
refresh_token	myRefreshToken

 

 

2 REPLIES 2

Rising Star

@azg  Yes, just add the values you want in the processor configuration tab.  Click + to add new key/value pairs.

Explorer

Thanks for your reply  @steven-matison .
I was trying to use FlowFile Form Data Name in the InvokeHTTP processor

azg_0-1648129645103.png


Someone gave me the right way to resolve my issue and it worked :

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.15.3/org.apach...

When the HTTP Method is POST, dynamic properties with the property name in the form of post:form:<NAME>, where the will be the form data name, will be used to fill out the multipart form parts.

so, post:form:<NAME> could be used for multipart/form-data

and you want application/x-www-form-urlencoded

format of http body should be parm1=Value1&parm2=Value2

before calling invokeHttp use replaceText with approximately this expression in replacement value:

client_secret=${client_secret:urlEncode()}&client_secret=${client_secret:urlEncode()}&...

then use invokehttp with

Send Message Body = true
Content-Type = application/x-www-form-urlencoded

 

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.