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
7
votes
1 answer

Faraday Authorization Header

I am trying to make a request to the Spingo API. I have made a successful request using Curl, but am trying to use the Faraday gem. The successful curl request looks like this: curl -v --url "calendarapi.spingo.com/v1/events?sections=42336" …
Aaron Wortham
  • 175
  • 1
  • 1
  • 10
7
votes
4 answers

Upload files using Faraday

I'm having issues attempting to upload a file to a web service using Faraday. My code: conn = Faraday.new('http://myapi') do |f| f.request :multipart end payload = { :file => Faraday::UploadIO.new('...', 'image/jpeg') } conn.post('/',…
anthonator
  • 4,915
  • 7
  • 36
  • 50
6
votes
0 answers

How to make persistent HTTP requests using multiple threads in Ruby/Faraday?

I'm using faraday with net-http-persistent adapter to make HTTP requests. I want to optimise my requests by making them execute asynchronously but as I need a persistent connection I keep getting errors such as too many connections reset which I…
Carla Urrea Stabile
  • 869
  • 1
  • 11
  • 35
6
votes
3 answers

Faraday Connection: Switching the request mode?

I am using faraday to handle some requests to an internal API. The API endpoints use a CSRF token, so I am also using faraday-cookie_jar. For a couple of the API endpoints, they require a :multipart request. Others do not. Question Is there any way…
Levi
  • 839
  • 2
  • 7
  • 21
6
votes
3 answers

How to set log level in faraday

I recently switched my http client to faraday and everything works as intended. I have the following piece of code to create a connection: @connection = Faraday.new(:url => base_url) do |faraday| faraday.use Custim::Middleware …
kauschan
  • 446
  • 2
  • 8
  • 21
6
votes
1 answer

# Connection refused - connect(2)

I am receiving the message # Connection refused - connect(2) after using checkboxes to select items in users/edit.html.erb and pressed save. The items I selected are in an array called amenities_list. These items are…
achilles77
  • 325
  • 2
  • 3
  • 11
6
votes
1 answer

Getting Faraday::Error::TimeoutError when creating card in Balanced gem

I am using the Balanced ruby gem in my rails app for payment integration. I am submitting card information and getting valid response. Then I send card information to my controller and in that I am creating buyer using card_uri. buyer =…
Kiran Chaudhari
  • 198
  • 2
  • 10
5
votes
1 answer

Faraday with net-http-persistent leaves connections open, resulting in "Errno::EMFILE: Too many open files"

We have a process (Rake task) that runs for a long period of time, making HTTPS requests to remote hosts using Faraday with the net_http_persistent adapter. After several hours to days of runtime, it stops making requests. The process is also making…
Robin Daugherty
  • 7,115
  • 4
  • 45
  • 59
5
votes
2 answers

How to send JSON as form data using Faraday's post method

How should I send this JSON in Faraday using the post method with the "application/x-www-form-urlencoded" and "multipart/form-data;" headers? message = { "name":"John", "age":30, "cars": { "car1":"Ford", "car2":"BMW", …
wuliwong
  • 4,238
  • 9
  • 41
  • 69
5
votes
2 answers

Faraday gem undefined method 'bytesize'=' for Hash`

I want to send a POST request to an API. Here's my code: conn = Faraday.new(url: BASE) do |faraday| faraday.response :logger faraday.request :url_encoded faraday.headers['Content-Type'] = 'application/json' faraday.headers["Authorization"]…
bav ko ten
  • 502
  • 7
  • 24
5
votes
1 answer

Faraday get access to the request parameters

Struggling a bit with faraday. I would like to know what I actually send to the server. I get the response body, but not access the request body. I found that there is a request.env method, but I can't get access to the body there somehow. How would…
Hendrik
  • 4,849
  • 7
  • 46
  • 51
5
votes
1 answer

keep-alive in ruby faraday

I have a method like this: def make_request(path, params, body) raise ArgumentError.new('Endpoint not set!') if url.nil? conditions = {url: url} conditions[:params] = params unless params.blank? connection =…
milodky
  • 443
  • 2
  • 7
  • 18
5
votes
0 answers

NameError: uninitialized constant Faraday::FlatParamsEncoder

I am using google_drive gem that depends on google-api-client and the gem versions are: google_drive (1.0.1) google-api-client (0.7.1) faraday (0.8.9) faraday_middleware (0.9.0) Now, on using GoogleDrive: session =…
5
votes
2 answers

Faraday JSON post 'undefined method bytesize' for has bodies

I'm trying to convert some code from HTTParty to Faraday. Previously I was using: HTTParty.post("http://localhost/widgets.json", body: { name: "Widget" }) The new snippet is: faraday = Faraday.new(url: "http://localhost") do |config| …
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
5
votes
1 answer

Set Faraday Timeout in Ruby ElasticSearch Client

Is it possible to set the timeout property of a Faraday transport when creating a Ruby Elasticsearch::Client? There is the scope to pass a block when initializing an Elasticsearch::Transport::Transport::Faraday instance, but when trying the below we…
DeejUK
  • 12,891
  • 19
  • 89
  • 169
1
2
3
18 19