I'm trying to get a protocol working with one of our devices, communicating over HTTP.
When calling the device API with an external tool (Postman or similar) it works without problem.
However when the dataminer protocol sends an HTTP request and a field value contains a localized character (in our case: å, ä or ö), the device responds with a 422:
"...malformed UTF-8 character in JSON string, at character offset 83 (before "\x{fffd}n 32","recor...")..."
Seeing as this problem does not arise when using an external tool I'm thinking this problem might be on the dataminer side. I do not add any Content-Type header so according to https://docs.dataminer.services/develop/schemadoc/Protocol/Protocol.HTTP.Session.Connection.Request.Headers.Header.html the request should be converted to UTF-8.
What am I missing?
Hi,
Is the protocol set as type with unicode option? See help. When this is not set as unicode then parameter values will still contain ascii characters.
Do note that changing a protocol to unicode is considered as a braking change so you might want to verify saved parameter values when using an existing element.
Regards,
That is because the protocol used to be an ascii by default, which saved the parameter values as ascii in the database. Now this has been changed into a unicode type, but the old saved values are still ascii which is now read out as strange characters. That is why changing the type to unicode is considered as a braking change for existing elements. The most easy thing to do is to create a new element and delete the old one. If you want to keep on using the existing element then you would have to log on into the database and delete the parameter data that is saved for that element, but that is not simple if you don’t have database knowledge. A step in between could be to temporary add a clear action to the protocol to be executed (once) on the table parameters to have the content deleted but that will only work for loaded data, the log lines with “Data not loaded” are still going to appear in the logging when (re)starting the element.
Alright, recreating the element it is. Thanks for the support Laurens!
This does indeed seem to solve it (although with some small quirks).
However the element seem to have saved a few rows in some of the tables with old indexes (now converted to some strange characters) keeping their display name but with the rest of the params as Not initialized. Is there a way to fix this without deleting and recreating the element?
Getting multiple log entries on startup like:
CParameter::ReadColumnData|ERR|-1|Table [65049/__Interfaces] Data not loaded, could not find primary key. Detected invalid data in DB for column pid: 65051, chIndex: 100001 and chValue: 4F007500740070007500740020003000.