Questions tagged [faraday]

Simple, but flexible HTTP client library, with support for multiple backends.

Faraday is an HTTP client lib that provides a common interface over many adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.

271 questions
3
votes
1 answer

Rails accessing keys in hashes from JSON data

I have a hash from a JSON object. It looks like this: JSON = {"kind"=>"calendar#freeBusy", "timeMin"=>"2012-02-19T19:35:00.000Z", "timeMax"=>"2012-02-19T19:40:00.000Z",…
William Stock
  • 63
  • 2
  • 6
3
votes
1 answer

Mocking a Faraday::Response object's `body`, and Nokogiri::XML::NodeSet

When trying to mock a Faraday::Response object, I've tried: mock(Faraday::Response, :env => {:body => "...some xml..."}) ...but this fails when I call response.body.xpath(...), because the body is a String, and it's expecting a NodeSet. Is there an…
jefflunt
  • 33,527
  • 7
  • 88
  • 126
3
votes
1 answer

Faraday is changing my headers from uppercase to capitalize case

I'm using Faraday to create an SDK that will interact with an API, and I need to send two headers API_SIGNATURE and API_REQUEST_TIME, so that's what I've created: class APIClient def initialize(api_key) @api_key = api_key end def…
user12212177
3
votes
1 answer

How to get the response from Faraday get request with token authentication?

I'm using Faraday with token authentication and unable to configure it to get the response. So far i'm writing it like this conn = Faraday.new(url: url) do |faraday| faraday.token_auth(ENV.fetch('API_TOKEN')) faraday.adapter…
Ahmad hamza
  • 1,816
  • 1
  • 23
  • 46
3
votes
4 answers

How to access the page protected by basic auth using Faraday?

I have a php page I want to access and that page is protected by basic auth. I know the url and username/password, they are listed below in code: url = 'https://henry.php' # note that it is a php website username = 'foo' password = 'bar' Faraday…
Henry Yang
  • 2,283
  • 3
  • 21
  • 38
3
votes
3 answers

Globally Configure Faraday User-Agent

I have inherited a Ruby project forked from CASinoApp, which depends on CASino, which uses Faraday for HTTP requests. I really do not want to fork CASino to modify how it invokes Faraday.post. Is there a way to configure Faraday globally to set it's…
Chris Trahey
  • 18,202
  • 1
  • 42
  • 55
3
votes
1 answer

Using Faraday to make HTTP requests over a Unix socket

I tried putting together a custom Faraday adapter to make HTTP requests using a Unix socket using NetX::HTTPUnix. The code looks like this: module Faraday class Adapter class NetHttpUnix < Faraday::Adapter::NetHttp def…
Aaron
  • 879
  • 7
  • 18
3
votes
0 answers

Why cant I change the session timeout for Patron when using Faraday in Ruby?

I am trying to change the connection timeouts for HTTP requests done with Faraday using Patron as the adapter. I try to change the timeout using the default_connections_options in my program as…
Nicolai
  • 3,698
  • 3
  • 30
  • 34
3
votes
1 answer

Cannot read big json response from Ruby

I have two projects which I call them Server and Client projects. In the Server side, I'm using a web service. I send a certain request to this web service, and it returns me a very long JSON response. Then I can do some business logic, and return…
esmrkbr
  • 275
  • 2
  • 7
3
votes
1 answer

How can I make a HTTP request from one docker container to another linked container?

I have a docker container with an sinatra app inside, and another container with an node.js app. They are both linked through Fig. In my sinatra app I am making a HTTP Post request to the node.js app. For that I am using the Faraday gem. My…
3
votes
2 answers

How to send JSON form data with Mechanize or Faraday in Ruby

I want to retrieve data from a website that uses JSON data to set custom search parameters which seem to be requested via AJAX. The data transmitted shows up under XHR->Request Payload in Firebug: {"filters": [{"action": "post", "filterName":…
Severin
  • 8,508
  • 14
  • 68
  • 117
3
votes
1 answer

Pass arbitrary connection options to Farday

I'm trying to convert a project I have from using Excon to Faraday with the Excon adapter, but I'm not having any luck. The issue is that I need to pass through some arbitrary connection options to Excon as the API I am interfacing with uses client…
Eugene
  • 4,829
  • 1
  • 24
  • 49
3
votes
1 answer

How do I debug HTTP of Ruby google-api-client

I'm trying to integrate with Google Drive, using the google-api-client. Since there's a lot of stuff going on, I would like to be able to see what's going over the wire (http level). It seems that the client uses Faraday for http connectivity. How…
troelskn
  • 115,121
  • 27
  • 131
  • 155
3
votes
0 answers

Rescue errors using Faraday and Syncrony

This is my first Ruby app and I'm having problems rescuing errors using Faraday with em_syncrony adapter, my code is like this: conn = Faraday.new(:url => "http://www.example.com") do |faraday| faraday.response :logger faraday.adapter …
Bruno R.
  • 51
  • 4
3
votes
1 answer

NoMethodError: undefined method `split' for # with Faraday

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…
Chris
  • 11,819
  • 19
  • 91
  • 145