- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Nifi - Getting JSON parse exception while making a curl call to rest api
- Labels:
-
Apache NiFi
Created on
‎01-27-2020
11:51 AM
- last edited on
‎01-27-2020
01:24 PM
by
cjervis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using execute stream command processor to make a curl call to rest api and getting below json parse exception.
Curl Call: (below command was extracted into a variable called curlcommand as mentioned in the screenshot)
--location;--request;POST;"https://abc.com/data";--header;${content_type};-d;"[{"bin": "02608","groupId": "52821094"},{"bin": "02609","groupId": "528212387"}]"
Exception:
{"timestamp":1580154052402,"status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('b' (code 98)): was expecting double-quote to start field name; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character ('b' (code 98)): was expecting double-quote to start field name\n at [Source: (PushbackInputStream); line: 1, column: 2] (through reference chain: java.util.ArrayList[0])","path":"/data"}
Please help..
Created on ‎01-27-2020 10:22 PM - edited ‎01-27-2020 10:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is your NiFi Version?
Looks like there is already a similar JIRA [1] Which seems to be addressing this behaviour of "ExecuteStreamCommand" in the NiFi version "1.10.0".
[1] ExecuteStreamCommand filters out any double quotes when parsing the "Command Arguments"
Created ‎01-28-2020 07:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jsensharma Thanks for your response.
We are using 1.7.
I changed ExecuteStreamCommand to InvokeHTTP processor.
Created ‎01-28-2020 05:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Escape the "s in the json data object:
"[{\"bin\": \"02608\",\"groupId\": \"52821094\"},{\"bin\": \"02609\",\"groupId\": \"528212387\"}]"
Let us know if this works, and if it does please accept this answer.
Created ‎01-28-2020 07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @stevenmatison.
I tried escape "s and still it is failing.
Created ‎01-31-2020 06:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@VijaySankar did you get it solved?
Created ‎10-16-2022 07:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
NO!
Created on
‎10-16-2022
07:24 AM
- last edited on
‎10-17-2022
09:08 AM
by
DianaTorres
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If double quotes are escaped, then the processor does not remove them, but the command is also sent with a backslash before the double quotes. does not work.
