Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

how to send dictionary in invoke http processor

Solved Go to solution

how to send dictionary in invoke http processor

Explorer

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

Accepted Solutions
Highlighted

Re: how to send dictionary in invoke http processor

Master Collaborator

@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

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

1 REPLY 1
Highlighted

Re: how to send dictionary in invoke http processor

Master Collaborator

@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

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

View solution in original post

Don't have an account?
Coming from Hortonworks? Activate your account here