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 8940073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:57:29+00:00 2026-06-15T10:57:29+00:00

I have this curl call: curl -v -H Accept: application/json -H Content-type: application/json -X

  • 0

I have this curl call:

curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"abc", "orgid":"12", "subject":"my subject"}' http://localhost:3000/mysinatraapp

post '/mysinatraapp' do
unless request.preferred_type.eql? 'text/html'
  # This is not really params hash. It will be a string like "{\"name\"=>\"abc\", \"orgid\"=>\"12\", \"subject\"=>\"my subject\"}"
    params = request.env["rack.input"].read 
    ...
    ...
    halt 400 if params.length == 0
end
  # This does not work
p "hi #{params['name']}"
end

p "hi #{params['name']}" fails because it’s not a hash. How do I make it work?

My goal is to make posted json as params hash. so that I can use params as usual.

  • 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-06-15T10:57:30+00:00Added an answer on June 15, 2026 at 10:57 am

    You are actually passing a Ruby Hash instead of a JSON object.

    Update your curl command to look like this:

    -d '{"name":"abc","orgid":"12","subject":"my subject"}'
    

    Then in your Sinatra action do like this:

    params = JSON.parse(request.env["rack.input"].read)
    

    Make sure you require 'json'

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

Sidebar

Related Questions

This is what I have so far: [my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv'
I have two virtual hosts, xyz.com and abc.com. From xyz.com I'm making curl post
I have the following Sinatra code: post '/bucket' do # determine if this call
I have a function that includes a call to CURL. This function takes about
I have an website. Let's call it http://www.domain.com . Now, on this domain.com I
I have a curl class, called Curl. Let's presume i have this code: $url
I cannot access to server through RestClient. I have this code written in cURL
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in
I have this application where I implement the ActionBar Fragment interface. Underlying the interface,
I have a REST web service class which i call HttpRequest using curl.I wrote

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.