I have FastAPI request and with a text input of "how are you?" and it works on the swagger page without issue:
curl -X 'POST' \
'https://xxxx.cloud/ai-chatbot/extract_text?q=how%20are%20you%3F' \
-H 'accept: application/json' \
-d ''
The issue is that when I pass "how are you?" on the ui, through the following JS code, I get 422 Unprocessable Entity. Here is the request:
var data = {
"msg": msg+" d",
}
$.ajax({
url: `${window.location.protocol}//${window.location.hostname}/ai-chatbot/extract_text?q=${data.msg+' d'}/1`,
data: JSON.stringify(data),
method: 'POST',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (res) {
var res = JSON.parse(res);
drawMessage(res)
},
error: function (err) {
if (err.desc == null)
err.desc = "Something went wrong!"
toastr.error(err.desc)
}
})
what's the issue that the server side works well but the request on the UI gives 422 error?
the issue is due to having question mark at the end of request. I tried adding space but it didn't work.