Skip to main content
Techie123
Silver ⭐️⭐️⭐️
Mar 21, 2023 11:11 AM UTC
Question

How to invoke api of Content-Type multipart/form-data using invokehttp processor in nifi

Hi Team,

 

How to invoke api of Content-Type multipart/form-data using invokehttp processor in nifi.

It's not working for me. 

 

If anyone has used the same, can you please share.

Thank you.

4 replies

steven-matison
Platinum ⭐️⭐️
Platinum ⭐️⭐️
Mar 21, 2023 12:46 PM UTC

@Techie123 to add headers in invokeHttp just click the + sign to add a new dynamic property, and set key to "Content-Type" and value to "multipart/form-data".   You will also need to make sure the rest of your invokeHttp is confirmed correctly. 

Depending on your version, you can also create and send an attribute called "Content-Type" of the same value.  Newest versions of NiFi will see a default property "Request Content-Type" which can also be set to attribute $mime-type which you can also define to suit your API.  

 

One other suggestion,  make sure you are testing remote API Calls with something like postman to confirm all the required values.   Then, work with NiFi after you have a known operational understanding for the api.

Translate
Techie123
Techie123Author
Silver ⭐️⭐️⭐️
Mar 21, 2023 12:57 PM UTC

Hi @steven-matison ,

 

I am using the same. I need to upload the file using this method. And also order of dynamic properties important. You know, have can i achieve it?

Translate
steven-matison
Platinum ⭐️⭐️
Platinum ⭐️⭐️
Mar 21, 2023 1:10 PM UTC

The file you need to send or upload to the api, should be the content of your flowfile that routes into InvokeHttp.   So some upstream process should read the file, and send the content through success relationship to InvokeHttp.   For example if this file is json,  I use GenerateFlowFile processor, put the json contents in there, then send to InvokeHttp.

Translate
Techie123
Techie123Author
Silver ⭐️⭐️⭐️
Mar 21, 2023 1:16 PM UTC

Yes, I am doing the same. And how to maintain the order of the dynamic properties in Invokehttp processor as the order is also important else it is saying bad request. Whenever i am adding those, these are automatically arranging the alphabetical orders instead the order on which i am adding 

Translate