S
S
shapeme2022-04-02 22:30:16
Bots
shapeme, 2022-04-02 22:30:16

How to remove this error when starting the telegram bot?

Hello everyone, the request looks like this:

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(" https://api.hh.ru/vacancies?text= " + it.message().text() + "&area=23"))
. build();


Full bot code here

When starting the bot, an exception occurs:
Caused by: java.net.URISyntaxException: Illegal character in query at index 35: https://api.hh.ru/vacancies?text=QA Automation&area=23

Earlier, I sent him a message "QA Automation", apparently he cannot process it and this prevents the bot from starting, the token was re-issued, how can I clear the bot's cache? Or is there a better way to solve

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2022-04-02
@sergey-gornostaev

https://en.wikipedia.org/wiki/Percent-encoding

S
shapeme, 2022-04-03
@shapeme

It was solved like this:
.uri(URI.create(" https://api.hh.ru/vacancies?text= " + it.message().text().replace(" ", "%20")))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question