Issue with passing locale to Claim Transformation

Soni, Ashish
21
Reputation points
Hi @Shweta Mathur @AmanpreetSingh-MSFT ,
Could you please help me with below issue?
We are using custom email service to send OTP for email verification. In order to achieve this, we are using ClaimTransformation to generate JSON request for the custom service.
In Extensions file, ClaimTransformation looks like this:
<ClaimsTransformations>
<ClaimsTransformation Id="GenerateEmailRequestBody" TransformationMethod="GenerateJson">
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" TransformationClaimType="email"/>
<InputClaim ClaimTypeReferenceId="otp" TransformationClaimType="otp"/>
</InputClaims>
<InputParameters>
<InputParameter Id="language" DataType="string" Value="{Culture:RFC5646}"/>
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="emailRequestBody" TransformationClaimType="outputClaim"/>
</OutputClaims>
</ClaimsTransformation>
</ClaimsTransformations>
When we try sending the request, our service gets only "en" as request. Expectation is to recieve a json request with email, otp and locale value. Other fields are not present in request.
Could you please confirm what am I doing wrong here?
Thanks
Ashish
{count} votes
Could you share the claim type of emailRequestBody you are defining?
B2C can only build a JSON from its own claim type primitives. Which are int, boolean, datetime, string, stringCollection.
Did you try to pass below in output claims
with these definiations:
and JSON output would be like
@Shweta Mathur Here it is:
@Shweta Mathur We need to pass user's locale in the emailRequestBody. Therefore, It can't be hardcoded.
When using Culture:RFC5646, the whole json is being replaced with a string "<user_locale>" . Ideally, it should replace only the value of language attribute.
@Soni, Ashish Did you tried using {Culture:LanguageName} in place of Culture:RFC5646 to get only ISO code for the language.
@Shweta Mathur Yes I did. It just replaces the whole JSON with the languageName.
Sign in to comment
1 answer
Sort by: Most helpful
Hi @Soni, Ashish ,
Thanks for reaching out.
I understand you are trying to get claim values ('email', 'otp') or constants ('en') to generate a JSON string but only getting locale value in the JSON.
To get claim values and constants to generate a JSON string, you need to add JSON objects to JSON array following dot notation which is used to indicate where to insert the data into a JSON string.
Hope this will help.
Thanks,
Shweta
Please remember to "Accept Answer" if answer helped you.
Sign in to comment