Through Rest API we are validating PhoneNumber and if PhoneNumber Exists we Pass Error Message in JSON but it is not showing

Rajadurai V 45 Reputation points
2023-06-22T13:26:36.1033333+00:00

@AmanpreetSingh-MSFT @Jas Suri @James Hail @Marilee Turscak-MSFT

we are trying to validate the PhoneNumber through REST API call. if the PhoneNumber Already Exists we send a JSON As Per Doc. sample JSON Structure below.

{
  "version": "1.0.0",
  "statusCode": 409,
  "userMessage": "User already exist with this phone number"
}

but it throws Error Message like below

'AF-PhoneNumberValidation' specified in step '3' returned HTTP error response with Code 'Conflict' and Reason 'Conflict'.

Below is the Rest API Call

<ClaimsProvider>
            <DisplayName>HTTP Request Technical Profiles</DisplayName>
            <TechnicalProfiles>
                <TechnicalProfile Id="AF-PhoneNumberValidation">
                    <DisplayName> Phone Number Validation </DisplayName>
                    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                    <Metadata>
                        <Item Key="ServiceUrl">URL</Item>
                        <Item Key="SendClaimsIn">Body</Item>
                        <Item Key="AuthenticationType">None</Item>
                        <Item Key="AllowInsecureAuthInProduction">true</Item>
                        <Item Key="HttpBinding">POST</Item>
                        <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item>
                    </Metadata>
                    <InputClaims>
                        <InputClaim ClaimTypeReferenceId="extension_phoneNumber"  PartnerClaimType="phoneNumber"/>
                    </InputClaims>
                </TechnicalProfile>
            </TechnicalProfiles>
    </ClaimsProvider>

calling this Technical Profile

<ValidationTechnicalProfiles>
            <ValidationTechnicalProfile ReferenceId="AF-PhoneNumberValidation" ContinueOnError="false"/>
            <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />
          </ValidationTechnicalProfiles>

Please let me know if we have missed out anything.

Thanks,

Rajadurai.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Jas Suri 91 Reputation points Microsoft Employee
    2023-06-22T15:45:31.71+00:00

    Follow this: https://learn.microsoft.com/en-us/azure/active-directory-b2c/restful-technical-profile#error-handling

    You canb change the error message displayed by making your API respond in the following way:

    {
      "version": "1.0.0",
      "status": 409,
      "code": "API12345",
      "requestId": "50f0bd91-2ff4-4b8f-828f-00f170519ddb",
      "userMessage": "
      "developerMessage": "Verbose description of problem and how to fix it.",
      "moreInfo": "https://restapi/error/API12345/moreinfo"
    }
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.