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.

Nifi - Getting JSON parse exception while making a curl call to rest api

Nifi - Getting JSON parse exception while making a curl call to rest api

Explorer

I am using execute stream command processor to make a curl call to rest api and getting below json parse exception.

 

curl.PNG

 

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..

5 REPLIES 5
Highlighted

Re: Nifi - Getting JSON parse exception while making a curl call to rest api

Super Mentor

@VijaySankar 

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"

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

Highlighted

Re: Nifi - Getting JSON parse exception while making a curl call to rest api

Explorer

@jsensharma Thanks for your response.

We are using 1.7.

I changed ExecuteStreamCommand to InvokeHTTP processor.

Highlighted

Re: Nifi - Getting JSON parse exception while making a curl call to rest api

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.

 


 


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

Highlighted

Re: Nifi - Getting JSON parse exception while making a curl call to rest api

Explorer

Thanks @stevenmatison.

I tried escape "s and still it is failing.

Highlighted

Re: Nifi - Getting JSON parse exception while making a curl call to rest api

@VijaySankar  did you get it solved? 

 


 


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

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