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.

Invalid JSON Unexpected character Error - POST request

Solved Go to solution

Invalid JSON Unexpected character Error - POST request

New Contributor

Hi,

 

I'm getting the JSON error when I'm making the post request. Please note that it works perfectly fine in Postman. Can some please help me out thanks.

 

Post body Template

 

 

 

{ 
   "format": "CSV",
   "filter": { 
      "createdAt": { 
         "startAt": 2020-06-20 16:33:19.780Z,
         "endAt": 2020-06-21 16:33:19.780Z
      },
      "activityTypeIds": [
         1               
         ]    
   }
}

 

 

 

Error code : "Invalid JSON. Unexpected character ('-' (code 45)): was expecting comma to separate Object entries"}]}

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Invalid JSON Unexpected character Error - POST request

@ajay_mamgain200   You need to quote your json values like this:

 

 

{ 
   "format": "CSV",
   "filter": { 
      "createdAt": { 
         "startAt": "2020-06-20 16:33:19.780Z",
         "endAt": "2020-06-21 16:33:19.780Z"
      },
      "activityTypeIds": [
         1               
         ]    
   }
}

 

 

You may need to modify the activityTypeIds too.   I commend your use of Postman for testing before implementing the test in NiFi.  This is exactly what I do to determine operational base sample call formats to a service before starting to implement in NiFi.  

 

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 @ DFHZ

 


 


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

2 REPLIES 2
Highlighted

Re: Invalid JSON Unexpected character Error - POST request

@ajay_mamgain200   You need to quote your json values like this:

 

 

{ 
   "format": "CSV",
   "filter": { 
      "createdAt": { 
         "startAt": "2020-06-20 16:33:19.780Z",
         "endAt": "2020-06-21 16:33:19.780Z"
      },
      "activityTypeIds": [
         1               
         ]    
   }
}

 

 

You may need to modify the activityTypeIds too.   I commend your use of Postman for testing before implementing the test in NiFi.  This is exactly what I do to determine operational base sample call formats to a service before starting to implement in NiFi.  

 

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 @ DFHZ

 


 


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

Highlighted

Re: Invalid JSON Unexpected character Error - POST request

New Contributor

Thank you it worked. I also used "1" for the number to make it work but it indeed worked.

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