Need to get the full https url from response body and click it

I am trying to get the full url value from response and click on the link to verify the email

my response

{
    "messages": [
        {
            "messageId": "1",
            "date": "Tue, 23 Jul 2024 00:44:19 +0000",
            "from": "[email protected]",
            "to": [
                "[email protected]"
            ],
            "subject": "Activation Link",
            "body": "Dear XXX,\n\n you need to verify your email address. Please enter the verification link . This link will be valid for five minutes.\n\nHere is your verificationLink: https://sample.com/verifyEmail?emailCode=IDpCK5%2FagNDdtCxss15Tm%2FKuhOs6q%2FwcjWVVXgLsQzX7TcXU593%2Bxz3LnW9GKgQdRKlPybNppHfJJ8hFewg0OvmRL26h1y%2BMFNlng2am6yFSw1IJ1gFNns5LfDYfQKn2WqJbujoFrnPCUwrAzdAacxGNNpmAGqUU4UiWbvWRw9C8C2IPItPd91AfDL4L5FPH8Bsox3g3Lbolg%2F98S80DIa2ysICav4ozf52al5lDfmSrR3kSV0SJB8J0lL8B5dfDeCPVyrmZMsA5x245hwrFHW9CrUuXLKwOJ%2FUMXJ2nd1Ul6i9%2F6%2BGYbtzPu8qXA%2B%2BImERt4eAfP4DsobbnOaPInDuP%2B7YSChONJ7dHRLN2Bz3Cl6qmZy6NtybqPI3mQB8vdMBN8QrMpl%2B2FLIxyLdtPbKFGYEulzRKwebKvyMJpjvFdOSU2EznC7ZAGqlFPtdu7JsD%2FIhOFZmNnBvkAXCAaeFH7GfDSY%2F9Pi8FMPHgP5QZHkZ6MaWBRwulO%2FspWOv2\n\nSincerely,\n*\n\nThis is an automated message, please do not reply."
        }
    ]
}

What i am trying to do in the code

let body = response.messages[0].body
        let authCode = body.match(/https:/g); 
        console.log("Link :: "+authCode)

it only retrieves only “https” . but i need the full url and click on that url.Please help

Hey @anita.christobel :wave:

Your regex would need to look something like this to get the full URL:

let body = response.messages[0].body
let authCode = body.match(/(https?:\/\/[^\s]+)/g); 
console.log("Link :: " + authCode[0])

The .match() would also return an array so you would been to access the first item using [0].

That would only log that out in the console, you wouldn’t be able to click on it to verify anything from there.

What do you mean by “click it”?

Depending on the API that is serving that email verficiation service, you might be able to setup a standard GET request to the retreived URL, or an sendRequest() function in a script.

However, there may be protections on the API that block non browser requests, so it will be a case of try it and see what happens.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.