Failure posting to Azure accented characters content

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

Post Reply
trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Failure posting to Azure accented characters content

Post by trevix » Tue Sep 26, 2023 1:45 pm

My standalone posts user registration data to Microsoft Azure, where the registration/login process is handled.

Today (sigh) after 2 years, I discovered that the post fails if there is an accented char on the registering user name.
Please note that the accented char is not a problem if the registration is made on Swagger, where it is successful .
Also, without accented characters the registration in LC is fine.

This example, on OSX 12.6.9, returns the following error (please note the "Paltò" in the user firstName):
it =
{"type":"https://tools.ietf.org/html/rfc7231#sec ... itle":"One or more validation errors occurred.","status":400,"traceId":"00-1ad5d3e469e824e44b14e473a6406fb3-46763b95ca722c4f-00","errors":{"$.firstName":["The JSON value could not be converted to System.String. Path: $.firstName | LineNumber: 0 | BytePositionInLine: 52."]}}
The data:
Json:
{"email": "testuser1@referi.io","firstName": "Paltò","TermsPrivacyConfirm": "2023-06-14 TermsAndPrivacy confirmed on 9/26/23","lastName": "User1","password": "SomePw","passwordConfirmation": "SomePw,"mobileNumber": "3406355631","sex": "M","age": "66","type": "User"}
Header:
Content-Type: application/json
Accept: application/json
Accept-Language: it-IT
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6....etc

The LC script goes like this

Code: Select all

...
put kURL into tURL --url to the DB
     put "/api/Authenticate/Register" after tURL
     put jsonExport(tArray) into tServerString --because the fastjsonLib in this case does not work
     put "Content-Type: application/json" & cr & "Accept: application/json" & cr & sHeaderLanguage & cr & "Authorization: Bearer " & sToken into tHeaders
     set the httpHeaders to tHeaders
     post tServerString to url tURL
     put the result into tNetworkErr -- status and/or errors show here
    put it --here the error descibed above
...
This can be a HUGE PROBLEM if I don't fix it right away.
Any idea of what could be wrong?
Thank you for any comment.
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Failure posting to Azure accented characters content SOLVED

Post by trevix » Tue Sep 26, 2023 2:26 pm

Sorry!
I wasn't using UTF-8 correctly on the content.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply