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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:42:11+00:00 2026-05-15T04:42:11+00:00

I am trying to communicate with a RESTful service in Rails. It can return

  • 0

I am trying to communicate with a RESTful service in Rails. It can return data in different formats, json and xml. Is there a specific way that I can get the data type that I want.

The service mentions that ACCEPT needs to be set in HTTP header. I am not sure how to do that in Ruby.

Currently I’m doing this for get

response = Net::HTTP.get( URI.parse( <url> ) )

I have no idea on how to change the header information for this call. Any help is appreciated. Thanks.

  • 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-15T04:42:12+00:00Added an answer on May 15, 2026 at 4:42 am

    I have got it working this way

    uri = URI( <domain>:<port>/<path> )
    params = { <query_hash> }
    headers = { <header_hash> }
    
    http = Net::HTTP.new(uri.host, uri.port)
    request = Net::HTTP::Get.new(uri.path)
    request.set_form_data( params )
    request = Net::HTTP::Get.new( uri.path+ '?' + request.body , headers)
    response = http.request(request)
    

    where query_hash is all the queries in hash ex: { "q" => "cats" }
    similarly for header_hash ex: { "ACCEPT" => "text/json" }

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

Sidebar

Related Questions

We are trying to communicate with a remote API which requires JSON formatted data.
How can I get my WCF service to communicate errors in a RESTful manner?
I'm trying to communicate AJAX, JSON to PHP and then PHP returns some data
i'm trying to communicate with my filesystem driver. I can start the driver with
I'm trying to communicate with a soap service and I know that I should
I am trying to develop a client application that calls a RESTful web service.
I am trying to communicate/update UI from Service to activity. The broadcast I receive
I'm trying to communicate with a RESTful API over SSL. The whole client application
I am trying to communicate with Google's spell check service using jQuery. Google's service
I am trying to communicate with a C# service from a native iPhone application.

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.