Skip to main content
ajay_mamgain200
Silver ⭐️
June 21, 2020
Solved

Invalid JSON Unexpected character Error - POST request

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"}]}

stevenmatison
Platinum ⭐️⭐️
June 21, 2020

@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

2 replies

stevenmatison
Platinum ⭐️⭐️
June 21, 2020

@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

Translate
ajay_mamgain200
Silver ⭐️
June 22, 2020

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

Translate