What would be the reason for the error Unexpected token < in json at position 0 when uploading a form ? converting to XML goes through without any mistakes, but when uploading it fails with this error.
Uploading the converted XML through the User Interface does work without any issues which was confusing to me.
Can you give more details? Pasting in output from where the error is (maybe cht-conf?) would be great.
With out knowing more, I’m pretty certain the code is expecting JSON but is instead getting HTML. Maybe double check the CHT instance is full up and running? It will sometimes return HTML instead of JSON when it’s partially down.
On top of what @mrjones has said, we also find this error occurs when using incorrect login details, because the API may redirect you to the login page which is HTML so starts with a < and breaks the JSON parsing.
This is what I am getting when uploading the file.
The html does sound like something that potentially could be happening as I am pulling the file with wget -O name.xlsx url - from a repo but I think then it shouldn’t even be converting to xml right?
Hi @nsaibirni
Can you check your server status? Specifically the logs would be very useful to check service health.
If you’re running CHT 4.x, then you can leverage this script to get the logs.