Support Questions

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

NIFI API REST - Upload Json definition flow file

avatar
New Contributor

hi everyone ! hoping everybody has an awsome day.

I am trying to create a process Group with a flow definition json i downloaded.

when i upload a file.json manually and checked the nifi-request.log and the only i see is this pettiotion " http://localhost:8081/process-groups/{id}/process-groups/upload

but i don't see the body in sent request, i want to use the api rest to upload this file but documentation is not clear in this aspect 

pettition #1:
curl
--location "http://localhost:8082/nifi-api/process-groups/{id}/process-groups/upload" \

--form "file=@/path/to/my/flowDefinition.json"

Response: Process Group name is required 

pettition #2:
curl
--location "http://localhost:8082/nifi-api/process-groups/{id}/process-groups/upload" \

--header 'Content-Type: multipart/form-data' \
-F 'id=root' \
-F 'name=QA_FLOW' \
-F 'position[x]=577.0' \
-F 'position[y]=11.0' \
-F 'clientId=27bf6df2-018c-1000-362e-61166913eee4' \
-F 'disconnectNode=true'
-F "file=@/path/to/my/flowDefinition.json"

Response: Process Group name is required 

no matter how hard i tried i could not find a way to upload this file or even make the API accepts the name parameter.
 
If someone can help me i would thanks a lot
have a nice day.  

1 ACCEPTED SOLUTION

avatar

Hi @Colombia ,

First of all you are right , the documentation seems to be lacking around this call. When I check the Nifi Rest API documentation under (Nifi-Api ) here is what I find for the upload api :

SAMSAL_0-1701894321710.png

For some reason the Name of all the parameters are not shown ! Not sure if they were missed by mistake or I'm missing something here @MattWho@steven-matison might know.

After trial and error using Postman I was able to get it working and here is the curl command as provided by postman:

 

curl --location 'https://{url}:9443/nifi-api/process-groups/17baf155-018c-1000-7bde-586d185d1d0d/process-groups/upload' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer ...' \
--form 'positionX="11.0"' \
--form 'clientId="4036074c-018c-1000-3e06-aaaaaaaaaaaa"' \
--form 'disconnectNode="true"' \
--form 'groupName="testapi"' \
--form 'positionY="557.0"' \
--form 'file=@"/C:/nifi-2.0.0-M1-bin/nifi-2.0.0-M1/test123.json"'

 

 

SAMSAL_1-1701894642365.png

 

If that helps please accept solution.

Thanks

View solution in original post

3 REPLIES 3

avatar

Hi @Colombia ,

First of all you are right , the documentation seems to be lacking around this call. When I check the Nifi Rest API documentation under (Nifi-Api ) here is what I find for the upload api :

SAMSAL_0-1701894321710.png

For some reason the Name of all the parameters are not shown ! Not sure if they were missed by mistake or I'm missing something here @MattWho@steven-matison might know.

After trial and error using Postman I was able to get it working and here is the curl command as provided by postman:

 

curl --location 'https://{url}:9443/nifi-api/process-groups/17baf155-018c-1000-7bde-586d185d1d0d/process-groups/upload' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer ...' \
--form 'positionX="11.0"' \
--form 'clientId="4036074c-018c-1000-3e06-aaaaaaaaaaaa"' \
--form 'disconnectNode="true"' \
--form 'groupName="testapi"' \
--form 'positionY="557.0"' \
--form 'file=@"/C:/nifi-2.0.0-M1-bin/nifi-2.0.0-M1/test123.json"'

 

 

SAMSAL_1-1701894642365.png

 

If that helps please accept solution.

Thanks

avatar
New Contributor

Hi @SAMSAL 

my friend, I just wanted to give you a huge thank you for your superhero-like assistance with the NiFi API on the community platform! Your solution was nothing short of amazing and saved the day in a way only a true superhero could.

Your expertise made a world of difference, and I'm incredibly grateful for your support.

Thanks a ton!

Best regards,

have a awesome day

avatar

@SAMSAL Thank you.  

 

For future reference.  If you ever need to figure out what the request is,  simply use NIFI UI to do the action you want while monitoring your Developer Tools.   This will expose the full request/response on any given UI action.

I have filed a JIRA for this.

https://issues.apache.org/jira/browse/NIFI-12503