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

  • Home
  • SEARCH
  • 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 8925607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:44:42+00:00 2026-06-15T07:44:42+00:00

I have this post request : curl -i -X POST \ -H Accept:application/json \

  • 0

I have this post request:

curl -i -X POST \
   -H "Accept:application/json" \
   -H "content-type:application/x-www-form-urlencoded" \
   -d "disambiguator=Document&confidence=-1&support=-1&text=President%20Obama%20called%20Wednesday%20on%20Congress%20to%20extend%20a%20tax%20break%20for%20students%20included%20in%20last%20year%27s%20economic%20stimulus%20package" \
   http://spotlight.dbpedia.org/dev/rest/annotate/

How can I write it in ruby? I tried this as Kyle had suggested:

require 'rubygems'
require 'net/http'
require 'uri'

uri = URI.parse('http://spotlight.dbpedia.org/rest/annotate')

http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({
                      "disambiguator" => "Document",
                      "confidence"    => "0.3",
                      "support"       => "0",
                      "text"          => "President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package"
                      })

request.add_field("Accept", "application/json")
request.add_field("Content-Type", "application/x-www-form-urlencoded")

response = http.request(request)
puts response.inspect

but got this error:

#<Net::HTTPInternalServerError 500 Internal Error readbody=true>
  • 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-15T07:44:44+00:00Added an answer on June 15, 2026 at 7:44 am

    You’ve since modified your question to include my initial response. In my initial answer, adding in the ‘Content-Type’ header causes it to be duplicated, remove the adding of that header and your example should work:

    This Cheat Sheet describes how to provide parameters to HTTP posts:

    require 'rubygems'
    require 'net/http'
    require 'uri'
    
    uri = URI.parse('http://spotlight.dbpedia.org/rest/annotate/')
    
    http = Net::HTTP.new(uri.host, uri.port)
    
    request = Net::HTTP::Post.new(uri.request_uri)
    request.set_form_data({
      "disambiguator" => "Document",
      "confidence"    => "0.25",
      "support"       => "0",
      "text"          => "President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package"
    })
    
    request.add_field("Accept", "application/json")
    
    response = http.request(request)
    puts response.inspect
    

    I tested this (on a Linux system) by setting the url to ‘http://localhost:9999’ and running netcat from another terminal:

    $ cat resp.txt
    HTTP 200 OK
    
    
    $ nc -l 9999 < resp.txt
    POST /this/that HTTP/1.1
    Content-Length: 223
    Content-Type: application/x-www-form-urlencoded, application/x-www-form-urlencoded
    Connection: close
    Accept: */*, application/json
    Host: localhost:9999
    
    disambiguator=Document&confidence=0.25&support=0&text=President%20Obama%20called%20Wednesday%20on%20Congress%20to%20extend%20a%20tax%20break%20for%20students%20included%20in%20last%20year%27s%20economic%20stimulus%20package
    

    This should cover both of your needs: sending form parameters as well as setting http headers.

    EDIT- By 0x90:

    that is what should be done:

    request.add_field("Accept", "application/json")
    
    request.set_form_data({
      "disambiguator" => "Document",
      "confidence"    => "0.3",
      "support"       => "0",
      "text"          => "President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package",
      "Content-Type" => "application/x-www-form-urlencoded"
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this curl call: curl -v -H Accept: application/json -H Content-type: application/json -X
I need to make a curl request, I have this line curl -X POST
I have this curl request below, which was successfully troubleshooted in another post. Right
I have been looking at this SO post: JavaScript post request like a form
When I make a post request using the following curl -i -d username=rock&password=rock http://my_VM_IP/api/1.1/json/my_login/
I am trying to form the following CURL post request through PHP? How do
I am using the following code to send a POST request using cURL. This
i have this problem to find a particular xml node l have post this
like in this post here by exemple I have found this blog but in
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to

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.