Support Questions

Find answers, ask questions, and share your expertise

Invalid JSON Unexpected character Error - POST request

avatar

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

avatar
Super Guru

@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

View solution in original post

2 REPLIES 2

avatar
Super Guru

@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

avatar

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