'Is it possible to make a x-www-form-urlencoded POST request through InvokeHttp

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
 

I try to made somethink with the FlowFile Form Data Name property enter image description here

But the request sended looks like this : enter image description here

I would like the key/value like this (sended as Content-type : application/x-www-urlencoded) : enter image description here



Solution 1:[1]

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.15.3/org.apache.nifi.processors.standard.InvokeHTTP/index.html

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 daggett