0

I'm using URI::HTTP library to build a URL I need to use to send to an endpoint.

ids = "12345,54504"

uri = URI::HTTP.build({
  :host => HOST,
  :path => '/endpoint',
  :query => {
    :ids => ids
  }.to_query,
})

The issue I am having is that the endpoint is expecting ids to be comma-separated. However, the URL that this builds replaces the comma with %2C. How do I get the url to just send the comma and not encode it.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
xeroshogun
  • 1,062
  • 1
  • 18
  • 31
  • Maybe you should pass it via json body? – Maxim Pontyushenko Jan 21 '16 at 20:01
  • 2
    `%2C` is the URL-encoded version of a comma. It is a universally valid and standard way to use a comma character in a query parameter, just as `%20` is the correct way to encode a space. The API endpoint should have no trouble decoding this correctly. If it can't, you should get in touch with the API provider so they can fix their API. – Jordan Running Jan 21 '16 at 20:09

1 Answers1

0

Don't worry the %2C is the URL-encoded of the comma.

You can try to create a route in your rails application and puts params[:ids], you will see your ids with the coma.

LolWalid
  • 515
  • 5
  • 15