Http Post Special Character Issue

Hi All,

I have a special character related issue, but not related to database but system.util.httpPost operation.

returnVal = system.net.httpPost(url = serverEndPoint, contentType = “Application/JSON”, postData = jsonString, connectTimeout = ConnTmeOut, readTimeout = ReadTimeOut, username = uname, password = pword, headerValues = {“Authorization”:auth}, bypassCertValidation = 1, throwOnError = 0)

print returnValue

This is expected to print “Grünberg” - which I can see when I call the web service from postman.

but in ignition it prints - ‘Grünberg’

I tried doing returnValue.encode(“utf-16”) but that did not help. Any clues!

Try adding a character encoding to your content type, eg Content-Type: text/html; charset=utf-8. Also, the script console in the designer doesn’t properly support unicode in the output buffer, so try writing the return value directly onto a label or text field in Vision, rather than printing it.

No This did not help: here is the change I made:

event.source.parent.getComponent(‘Text Area’).text = system.net.httpPost(url = serverEndPoint, contentType = “Application/JSON;charset=utf-8”, postData = jsonString, connectTimeout = ConnTmeOut, readTimeout = ReadTimeOut, username = uname, password = pword, headerValues = {“Authorization”:auth}, bypassCertValidation = 1, throwOnError = 0)

I also tried utf-16.

Can you use a tool like wireshark to make sure that the value coming into Ignition is correct? I’m not sure what would be mangling the encoding when it comes in.

It might be interesting to stick the value into a tag or label too. It could just be the script console itself that has a problem.

I also tried running it in Postman, which shows the expected output.

not doing it in script consol anymore. :slight_smile:

I had a similar problem with httpGet
I could get my special characters displayed properly (è, à, etc) with a combination of decode and encode:

EndUrl = “…”
results = system.net.httpGet(EndUrl)
results = results.encode(‘latin-1’).decode(‘utf-8’)
print results

1 Like