- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Double Quotes removed from JSON message when passing an attribute to ExecuteScriptCommand Processor
- Labels:
-
Apache NiFi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using two steps in Nifi:
1. The first step is InvokeHTTP processor to make a REST API call and receive a JSON response. I have used "Put Response Body In Attribute" to store the JSON response into an attribute.
2. The next step is ExecuteStreamCommand processor to invoke Python script and passing the JSON response attribute from previous step as an input argument. The Command Argument passed to the processor is:
/home/kavipriya/script/Scaling.py;"${AssetModel}";
I am able to read the JSON message within my python script, but the double quotes within original JSON message are removed by Nifi and I get following error when parsing the JSON message:
"json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 3 column 5 (char 10)"
Can someone tell me why are the double quotes removed when JSON message passed as argument and also if there is an option to retain the double quotes. Thanks for your help!
I have attached the screenshots and also the JSON message passed to python script and also the python logs showing double quotes missing when reading the argument.
Created ‎10-01-2019 02:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Python Script
Nifi Flow
Logs written by Python Script
Data Provenance view
Created ‎11-23-2021 12:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I'm having the same problem with the double quotes being removed when you pass a JSON into the ExecuteStreamCommand. Have you been able to find a solution?
Created on
‎10-16-2022
07:21 AM
- last edited on
‎10-17-2022
09:06 AM
by
DianaTorres
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A similar situation. the process automatically removes the double quotes and already passes without them. if escaped, the process does not remove them, but leaves a backslash before the double quotes. It is advised to define a strategy for passing arguments, but so far I have not found examples of how to do this. If anyone has an algorithm for creating such a strategy, please share.
