Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Apache NiFi processor 'InvokeHTTP' POST with MultipartFile formdata to remote API

avatar
Contributor

I have have two request formdata param. One param is file which is multipart and another is acno which is string. Here is the postman image:

 

enam_0-1703175166404.jpeg

Postman request is working fine. This postman request, I want to process using Apache Nifi. Here I have tried to use below image in apache nifi:

enam_1-1703175252704.jpeg

But when start above aldiagram file & acno not found

Here is screen steps:

1. GetFile screen :

enam_2-1703175461520.jpeg

2. Update Attribute screen:

enam_3-1703175506854.jpeg

3. AttributeToJson screen:

enam_4-1703175607344.jpeg

4. InvokeHTTP screen:

enam_5-1703175639958.jpeg

I follow steps above screen --> Getfile->UpdateAtribute->AttributeToJson->InvokHttp

What is the wrong of my configuration?

Please help me...

2 ACCEPTED SOLUTIONS

avatar

Hi @enam ,

Not sure where you set the acno  parameter , I cant see it in the UpdateAttribute. Make sure the value is available before the invokeHttp as flowfile attribute. Once you have that and you want to send it as  multipart form request you need to add dynamic property with the following format per the documentation (https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.17.0/org.apach...

SAMSAL_0-1703177700176.png

So in your case  the dynamic property will look like the following:

SAMSAL_1-1703177797735.png

In this case you probably dont need the AttributeToJson processor.

If that helps please accept solution.

Thanks

 

 

View solution in original post

avatar

I did a test on a multipart file upload api and it worked for with the following properties:

SAMSAL_2-1703193927420.png

No need to add dynamic properties for Content-Disposition & Content-Type. There is a property already for the Content-Type called "Request Content-Type".

View solution in original post

7 REPLIES 7

avatar

Hi @enam ,

Not sure where you set the acno  parameter , I cant see it in the UpdateAttribute. Make sure the value is available before the invokeHttp as flowfile attribute. Once you have that and you want to send it as  multipart form request you need to add dynamic property with the following format per the documentation (https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.17.0/org.apach...

SAMSAL_0-1703177700176.png

So in your case  the dynamic property will look like the following:

SAMSAL_1-1703177797735.png

In this case you probably dont need the AttributeToJson processor.

If that helps please accept solution.

Thanks

 

 

avatar
Contributor

@SAMSAL  thanks for your reply.

 

 

avatar

My understanding is the file "file.xls" will be uploaded and the file name is stored under filename attribute (make sure to set the file name and extension correctly in the UpdateAttribute as file.xls) , Also make sure the following properties are set as follows:

Request Body Enabled : true

Request Multipart Form-Data Filename Enabled : true

The later will set the Content-Disposition accordingly based on the filename attribute so you dont have to add as dynamic property.

Hope that helps.

 

 

avatar
Contributor

@SAMSALthanks again for your reply.  You describe it clearly. I have updated myfile. but still show file not exist. sorry for disturb you again

Here is the update attribute:

enam_0-1703184972698.png

My invokeHttp:

enam_1-1703185476642.png

Please help me..

avatar

I did a test on a multipart file upload api and it worked for with the following properties:

SAMSAL_2-1703193927420.png

No need to add dynamic properties for Content-Disposition & Content-Type. There is a property already for the Content-Type called "Request Content-Type".

avatar
Contributor

Dear Samsal,  thank you very much for providing me your valuable  support. It is working now. You save me full weak...Thanks again

avatar
Explorer

Hello, I m performing almost the same request and facing some difficulties, anyone can help plz?

I m sending multipart request from Nifi 1.18, but in my case the 1st part should be binary (gzip) and named (data) and the second part should be json file and named (parameters). this works corretly with post man

bou7miiiz_0-1709647893390.png

but I m not able to do the same thing with Nifi 1.18

this is my workflow

bou7miiiz_1-1709648002017.pngbou7miiiz_2-1709648062494.png

 

 

bou7miiiz_3-1709648279300.pngbou7miiiz_4-1709648400029.png