Skip to main content
January 3, 2025
Question

Web API for portal Email validation

  • January 3, 2025
  • 5 replies
  • 0 views

Hi Experts,

I have created a WEB API in which i am validating IP Address and email. Based on that I have created Integration which called that WEB API . Then In integration if I pass IP parameter null and only email is passes than it gave an error. 

Please help me how can handle it .

Below is WEB API :

a!localVariables(
  local!invalidipAddress: a!flatten(
    a!forEach(
      items: split(
        split(
        http!request.queryParameters.targetIp,
        " "
      ),
      char(10)
      ),
      expression: rule!CDM2_ER_IP_Address_Validator(fv!item)
    )
  ),
  local!isInvalidEmail: if(
    a!isNotNullOrEmpty(http!request.queryParameters.email),
    not(rule!CDM2_ER_Email_Address_Validator(http!request.queryParameters.email)),
    false() /* If no email is provided, assume valid */
  ),
  local!confirmIP: {
  ipInfo:if(
      and(
        a!isNotNullOrEmpty(http!request.queryParameters.targetIp),
        length(local!invalidipAddress) > 0
      ),
      "Entered IP Addresses either Invalid or Private IP Addresses :  " & local!invalidipAddress,
      /*false(),*/
      true()
    ) ,
    emailInfo: not(local!isInvalidEmail) /* True if email is valid */
  },
  a!httpResponse(
    statusCode: 200,
    headers: a!httpHeader(
      name: "Content-Type",
      value: "application/json"
    ),
    body:a!toJson(
      {
        ipValidation: local!confirmIP.ipInfo,
        emailValidation: local!confirmIP.emailInfo
      }
    )
  )
)

Integration Error :

5 replies

stefanhelzle0001
January 3, 2025

Did you test that API with the targetIp set to null?

January 5, 2025
I am calling this web api on two different interfaces. I want that if any one of the parameters is missing then also the integration given success true.
stefanhelzle0001
January 5, 2025

You can test your API from inside the Web API Designer. I suggest to use this to make it behave as expected.

somasundaram.d
January 6, 2025

Are you able to connect to the API via integration for any other case?