HttpMessage NotReadableException API

Dear All,

I have some issue. I set variable in an api object but when I hit from Katalon it give response 400 HttpMessageNotReadableException and when I hit without variable like norma date format it success, I still don’t get it, why when I set variable it get’s HttpMessageNotReadableException

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Hi @coldplays6371,

Welcome to our community. Which variable makes your test fail? Can you please share the code?

hi @coldplays6371

HttpMessageNotReadableException is spring saying the body is not valid json any more once your variable is in. with a date variable it is almost always one of two things.

one, double quotes. the body has “${date}” and the variable value already contains quotes, so the server sees "“2024-05-31"”. or the opposite, the variable is used without quotes and the value has none.

two, the variable is not a string. if the default value is something like new Date() the body ends up with Fri May 31 16:11:05 ICT 2024 instead of your format. format it first:

new Date().format('yyyy-MM-dd')

easiest way to see which one it is: add println request.getBodyContent().getText() to the verification tab, run, and paste the body into a json validator. the broken character jumps out immediately.