I’m learning how to make telegram bots. With webhook telegram send you a post request with some message.
I want my server to get this request, process and send new request to telegram get/post.
For example:
telegram bot sent me a post request with a new message in chat.
i get this request and proccess it.
now i need to send new get request to telegram to post a message like https://api.telegram.org/bot/sendMessage?chat_id=&text=hello
Is there a way to send request directly from controller? I know that i can redirect request, but redirect can be only GET and i need completly new request.
2
Answers
you can use Rest Template to send request to a web service.this is a spring guide on how to do it.
You can either use Spring’s RestTemplate:
Or use the newer Spring WebClient for this. See this link for example.