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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:44:02+00:00 2026-06-05T04:44:02+00:00

I want to send a get request with a JSON body (for search) using

  • 0

I want to send a get request with a JSON body (for search) using Faraday, but am getting the above error. I thought that self inside the Proc was messing things up, but that had nothing to do with it. I’m following the documentation on the [faraday github page][1] but have gotten stuck on this.

def perform_query
  response = self.database.connection.get do |request|
    request.url self.path
    request.headers['Content-Type'] = 'application/json'
    request.body(self.to_json)
  end
end

def terms_to_json
  terms_array = self.terms.keys.inject([]) do |terms_array, field|
    value = self.terms[field]
    terms_array.tap do |ary|
      if value
        ary << "\"#{field}\": \"#{value}\""
      end 
    end
  end

  "{ #{terms_array.join ','} }"
end

def to_json
  "{ \"queryb\" : #{self.terms_to_json} }"
end

Here is the stack trace, with the error coming somewhere in the get Proc in #perform_query :

from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/request.rb:60:in `url'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/connection.rb:219:in `block in run_request'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/connection.rb:237:in `block in build_request'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/request.rb:35:in `block in create'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/request.rb:34:in `tap'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/request.rb:34:in `create'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/connection.rb:233:in `build_request'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/connection.rb:218:in `run_request'
    from /Users/chrismaddox/.rvm/gems/ruby-1.9.3-p125/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in `get'
    from /Users/chrismaddox/Dropbox/LivingSocial/Hungry Academy/Projects/hackchat/search_ruby/elastic.rb:83:in `method_missing'
    from /Users/chrismaddox/Dropbox/LivingSocial/Hungry Academy/Projects/hackchat/search_ruby/elastic.rb:112:in `perform_query'
    from /Users/chrismaddox/Dropbox/LivingSocial/Hungry Academy/Projects/hackchat/search_ruby/elastic.rb:61:in `send_query'

UPDATE:

the path method returns a string of the path to the search for a given index. Eg /wombats/animals/_search

Elastic::Database#path calls Elastic::Index#index_path:

module Elastic
  ELASTIC_URL = "http://localhost:9200"


  class Index
    attr_reader :index_name, :type_name, :last

    def initialize(type)
      @index_name = "#{type}-index"
      @type_name = type
      @last = 0
      add_to_elastic
    end

    def add_to_elastic
      index_url = URI.parse "#{ELASTIC_URL}#{index_path}/"
      Connection.new(index_url).put()
    end

    def index_path
      "/#{self.index_name}"
    end

    def search_path
      "#{type_path}/_search/"
    end

    def type_path
      "#{self.index_path}/#{type_name}/"
    end

  end
end
  • 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-05T04:44:04+00:00Added an answer on June 5, 2026 at 4:44 am

    A call to search_path = "#{type_path}/_search/"
    A call to type_path = "#{self.index_path}/#{type_name}/"
    A call to index_path = "/#{self.index_name}"

    So if index name is wombat and type name is animal, search_path evaluates to /wombat/animal//_search

    It turns out that this wasn’t the problem showing the error, but was caused because Faraday’s methods are inconsistent. Faraday::Request#url and Faraday::Request#headers are themselves setter methods, whereas Faraday::Request#body= is the setter method for body.

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

Sidebar

Related Questions

I want to send JSON request through HTTPConnection but i am getting error when
I have data that I want to send through an ajax GET request in
I want to send a request to another server from my servlet and get
i want to send json to server using Spring 3.x, i use annotation @RequestBody,
I need to use a GET request to send JSON to my server via
I want to send a get request to twitter to return a large number
As per client requirement i want to send crash Report when App get crash.
I want to to get the access token from LinkedIn. First I send the
I want send a email by Email Class in codeigniter with gmail, but i
I want to create a dictionary containing array and send it to GAE using

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.