SSO Login Failure When User Email Contains an Apostrophe

0
Hi Mendix Community,I’m facing an issue with SSO login in a Mendix application for a specific user.The user is unable to log in because their email address contains an apostrophe ( ' ) in the username part of the email address.During the SSO login flow, we are calling Microsoft Graph API to retrieve the user details. We are using the Email Id as part of the search URL endpoint, similar to:"https://graph.microsoft.com/v1.0/users?$filter=mail eq 'user's.email@example.com'"The API call fails because the apostrophe in the email value conflicts.For example, if the email is:"user's.email@example.com"What is the recommended way in Mendix to handle an apostrophe in an email address when constructing the Microsoft Graph API URL?I would appreciate any guidance or example implementation for handling special characters in email addresses during Microsoft Graph API calls.Thank you!
asked
1 answers
0

I believe this is because the apostrophe is used as a quote in some graph queries. So, to use the apostrophe in the API call, you would need to escape it. This is done by adding another apostrophe.


So in your Mendix application, you can use the ReplaceAll function to look for apostrophes, and if found, add another one next to it. Mendix also needs apostrophes to be doubled, so assuming the email address is in a variable called $vEmail, the following should work.


replaceAll($vEmail, '''','''''')


https://docs.mendix.com/refguide/string-function-calls/#replaceAll

I hope this helps.

answered