A
A
Andrey2017-10-18 10:40:52
Ruby on Rails
Andrey, 2017-10-18 10:40:52

How to send Cyrillic in GET request?

When trying to make a get request for

Net::HTTP.get(URI.parse("http://api.boxberry.de/json.php?method=ListPoints&CityCode=Н00030681"))

Returns an error URI::InvalidURIError - bad URI(is not URI?)
In general, this is due to the fact that in the parameter that I send (city code) CityCode=Н00030681N is Cyrillic.
And it turns out that I make such a requestStarted GET "/delivery.json?code=%D0%9D00030681"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2017-10-18
@andreychumak

JSON.parse(
  Net::HTTP.get(
    URI.parse(
      URI.encode("http://api.boxberry.de/json.php?method=ListPoints&CityCode=Н00030681")
    )
  )
)
=> [{"err"=>"Нет доступа"}]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question