Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

how to send dictionary in invoke http processor

avatar
Contributor

hi everyone ,

We want to put data in web app using API endpoint 

https://localhost:8000/api/event/${id}/attributes this is the API endpoint that i have used in invoke HTTP processor in Remote URL field with PUT method. 

we want to create new attribute with value and this attribute is a dictionary type so we have to pass the data in the dictionary format for this we have used updateattribute processor and attributetojson processor. 

updateAttribute processor snap

renuu_0-1591268658480.png

Attributetojson processor snap

renuu_1-1591268717755.png

and the below is out of attributetoJson processor (flowfile)

{"note":"note from nifi","attributes":"{\n \"workflow\":\"process\"\n }","id":"1ecfbcbb-38bf-49e9-a77e-a88w"}

 

the error msg in invoke http processor 

{ "code": 500, "errors": [ "Traceback (most recent call last):\n File \"/usr/local/lib/python3.6/site-packages/flask/app.py\", line 1949, in full_dispatch_request\n rv = self.dispatch_request()\n File \"/usr/local/lib/python3.6/site-packages/
No value set
 
as per my knowledge this is type error. I think the Dictionary is not sending in correct format . i have also used ${attributes:unescapeJson()} in updateAttribute ...but i think i have made a mistake in the declaration
property_nameproperty_value
attributes{"workflow": "process"}
'attributes' ${attributes:unescapeJson()}
 
 thanks 

 

1 ACCEPTED SOLUTION

avatar
Super Guru

@renuu You have to build the final values you want as separate key value pairs like this:

UpdateAttributeUpdateAttribute

Next you will use these attributes  to create a json object attribute using AttributesToJson:

 

AttributesToJson flowfile-attributeAttributesToJson flowfile-attribute

 

After that, if you inspect the flowfile you will see the json object as JSONAttributes:

 

FlowFile Attribute JSONAttributesFlowFile Attribute JSONAttributes

 

From here you can use it as ${JSONAttributes} or if you need it to be called ${attributes} you just use another UpdateAttribute:

 

Screen Shot 2020-06-04 at 8.27.00 AM.png

View solution in original post

1 REPLY 1

avatar
Super Guru

@renuu You have to build the final values you want as separate key value pairs like this:

UpdateAttributeUpdateAttribute

Next you will use these attributes  to create a json object attribute using AttributesToJson:

 

AttributesToJson flowfile-attributeAttributesToJson flowfile-attribute

 

After that, if you inspect the flowfile you will see the json object as JSONAttributes:

 

FlowFile Attribute JSONAttributesFlowFile Attribute JSONAttributes

 

From here you can use it as ${JSONAttributes} or if you need it to be called ${attributes} you just use another UpdateAttribute:

 

Screen Shot 2020-06-04 at 8.27.00 AM.png