RGZ
RGZ

Reputation: 61

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

I just started using Nifi and 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 make something with the FlowFile Form Data Name property:

enter image description here

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

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

Upvotes: 1

Views: 1586

Answers (1)

daggett
daggett

Reputation: 28634

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

Upvotes: 3

Related Questions