Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7170995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:19:25+00:00 2026-05-28T15:19:25+00:00

I am doing an http get using the url http://localhost/add?add_key[0][key]=1234&add_key[0][id]=1. I have a rails

  • 0

I am doing an http get using the url http://localhost/add?add_key[0][key]=1234&add_key[0][id]=1.
I have a rails app which gives me a neat params hash {“add_key”=>{“0″=>{“key”=>”1234”, “id”=>”1”}}. However when I try to post this to a different server using

new_uri = URI.parse("http://10.10.12.1/test") 
res = Net::HTTP.post_form new_uri,params

The server handling the post is seeing this parameter in the request

{"add_key"=>"0key1234id1"}

Looks like post_form requires a String to String hash. So how do I convert the params hash to

{"add_key[0][key]" => "1234", add_key[0][id]" => "1"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:19:26+00:00Added an answer on May 28, 2026 at 3:19 pm

    From the fine manual:

    post_form(url, params)
    Posts HTML form data to the specified URI object. The form data must be provided as a Hash mapping from String to String.

    So you’re right about what params needs to be.

    You could grab the parsed params in your controller:

    {"add_key"=>{"0"=>{"key"=>"1234", "id"=>"1"}}
    

    and then recursively pack that back to the flattened format that post_form expects but that would be a lot of pointless busy work. An easy way to do this would be to grab the raw URL and parse it yourself with URI.parse and CGI.parse, something like this in your controller:

    u = URI.parse(request.url)
    p = CGI.parse(u.query)
    

    That will leave you with {"add_key[0][key]" => "1234", "add_key[0][id]" => "1"} in p and then you can hand that p to Net::HTTP.post_form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just doing a simple graph using Open Flash Chart http://teethgrinder.co.uk/open-flash-chart/ which shows the
Using the code generated by restful_authentication, we usually get 'localhost' as the URL in
I'm trying to use Net::HTTP.get_print in a rails app to get the response from
What am I doing wrong ? My URL : http://localhost:8000/login/ The DEBUG log from
hudson supports submitting a build by doing an HTTP GET to an API. I
I am doing: html = new WebClient().DownloadString( http://www.google.com/search?sourceid=chrome&ie=UTF-8&q= + biocompany); and i am getting
i'm using this example implementation found at http://tangentsoft.net/wskfaq/examples/basics/select-server.html This is doing most of what
Hi I am trying to get a String out of URL. I am using
I'm trying to shorten a URL using the http://goo.gl API with the following jQuery
I got my url from the app. It begins with: http://sn1.notify.live.net/throttledthirdparty/01.00/ and if I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.