How to integrate third party API in your Spring boot project discussion with a Subscriber .

Опубликовано: 12 Октябрь 2024
на канале: Ramanpreet Singh
812
5

Hi everyone , This is first of its kind . I wanted to have calls with my Subscribers to discuss there queries and Resolve them on calls . And one of my Subscriber approached with very good query . So , I though it would be great if I can share the query and Solution with all of you . The best part is the Subscriber resolved his query by himself , Great .So , hope you enjoy the conversation .

Query Asked :
In TwoStepVerification Project , he wanted to use some external api to send email , rather then integrating his project with Gmail , so the steps to get to the query

1. First you will Register a user.
2. You will Login using your credentials.
3. Then this api which you shared will be sending otp to your registered email right?
4. And then you consume the response of the above api and then show the dashboard.

Code Solution which we did , we already have discussed in call , but sharing the code snippet
private void sendMail(User user) {
RestTemplate restTemplate = new RestTemplate();

String apiUrl = "https://r67fjrura6.execute-api.ap-sou...";

int otp = user.getOtp();
String email = user.getEmail();
String urlWithParams = apiUrl + "?otp=" + otp + "&email=" + email;
String response = restTemplate.getForObject(urlWithParams, String.class);
}

Hope it helps other people as well .
Do like , share and comment .
If new to the channel please SUBSCRIBE and press the bell icon

You can write your queries to me at - [email protected]