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

How to customize stub request using Faraday?

I'm trying to customize stubs via Faraday and have a little problem with setting request_body and request_headers. All test works and are green, but I'm still getting message by Rubymine: „Found extra argument“ and that part of the code is…
Pavel
  • 15
  • 3
0
votes
0 answers

how to specify the file path for a telegram document send?

Trying to send my log file to my Telegram group when they request it. File 'log.log' is located in the same directory @t_a = ENV['TELEGRAM_API_KEY'] def send_log(chatid) file = "log.log" url = "https://api.telegram.org" u =…
seamus
  • 2,681
  • 7
  • 26
  • 49
0
votes
1 answer

Rails upload pdf file via POST request

In my Rails 7 app third party API require to send the PDF file created by my application. I've got sample curl from the API docs: curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' {"type":"formData"}…
tajfun_88
  • 41
  • 6
0
votes
0 answers

Not getting any records from elasticsearch-rails. Getting undefined method `each_pair' for "{\"success\":true}"

While accessing the records I am getting the following error... $ response.records NoMethodError: undefined method `each_pair' for "{\"success\":true}":String corresponding curl request in log gives another result $ curl -X POST -H…
0
votes
0 answers

Elaticsearch Failed to open TCP connection to localhost:9200

require 'faker' require 'async' require 'newrelic_rpm' NewRelic::Agent.manual_start class Movie attr_reader :attributes def initialize(attributes={}) @attributes = attributes end def to_hash @attributes end end require…
Siva Gollapalli
  • 626
  • 6
  • 20
0
votes
1 answer

Pass image to STDIN for ffprobe to read in Ruby

I have a script that is currently using wget to grab an image from a url then passing that image to ffprobe. I'd like to remove the wget dependancy. What is the best way to download this image from the URL into STDIN so that ffprobe can read…
halorrr
  • 1
  • 1
0
votes
1 answer

Faraday::ConnectionFailed | Net::OpenTimeout execution expired

I’m testing a request using the faraday gem. For some reason, this request /login works locally but not when deployed to Heroku or Render. I get always the same error: Faraday::ConnectionFailed execution expired domain:443 with…
0
votes
0 answers

Rails 7 Faraday Adapter stub shows an error Faraday::Adapter::Test::Stubs::NotFound

I need to deal a lot with one external API. Each instance should give access to namespace resources, e.g. client.accounts.payout_history, client.accounts.list. To do so I've created a client using Faraday gem which now I want test by RSpec with…
mr_muscle
  • 2,536
  • 18
  • 61
0
votes
0 answers

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

I want to POST request, using Ruby gem Faraday. Content-Type is "application/pdf". my code is below. client = Faraday.new(endpoint) do |client| client.request :retry client.headers['Content-Type'] = "application/pdf" …
0
votes
1 answer

How to send url-encoded form data using Faraday's post method?

I'm trying to setup Faraday to make requests to a Twilio API. I can make the requests via Postman setting up the key/values in the request body as x-www-form-urlencoded data. When I try to replicate the cURL I make on Postman in Rails I get an error…
pinkfloyd90
  • 588
  • 3
  • 17
0
votes
0 answers

Check if the URL is valid and exists in Ruby on Rails - Faraday Timeout problem

Faraday::TimeoutError in Spree::Products#show , Net::ReadTimeout with #TCPSocket:(closed) So i am trying to check if the URL is valid and exists, i tried sending request_head with http to get the response, i also did the same with faraday. My…
Niss
  • 1
  • 3
0
votes
0 answers

How to create a custom formatter for Faraday logging?

In the Gemfile, the gem is listed like this: gem "faraday" This leads to the installation of the current version 1.10.0. Then, following this documentation, I create a custom logger, but I get an error: NameError: uninitialized constant…
Colibri
  • 993
  • 11
  • 29
0
votes
1 answer

Rspec: Mocked payload is returning nil instead of the actual object created for testing purposes

I've created the following service class ApiCustomers < ApiBase def initialize(url: nill) url = url.presence || ENV.fetch("CUSTOMERS_API_APP_NAME") super(url) end def find_customer_apps(customer_id, params=nil) begin …
RubyLearning
  • 83
  • 1
  • 7
0
votes
1 answer

Ruby's Faraday - Send optional parameters in get method

I have an endpoint with multiple optional parameters. def get_customers(params=nil) if params.nil? customer_url = "#{@url}/customers" # call api response = connection.get(customer_url) else # I do not know how to write…
RubyLearning
  • 83
  • 1
  • 7
0
votes
1 answer

How can i retrieve query params from get request

I'm kind of new to Ruby and I stuck with a fairly simple task. I would like to pass GET parameters to Faraday's request. Here is my request function def request @request ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.headers =…
Andrew
  • 1,507
  • 1
  • 22
  • 42