All Questions
Tagged with rest-client ruby
321 questions
1
vote
0
answers
77
views
In Ruby, how to send multiple files in single request using RESTClient
I've been have a issue where I tried to use the RestClient lib to send two or more files to Kotlin Service endpoint where this controller needs to receive a files attributes that is a List<...
0
votes
1
answer
43
views
Ruby's rest-client isn't replicating my CURL request, and I don't know what I'm doing any differently
Here's my CURL request:
curl -X POST -u apikey:secret 'https://numbers.api.sinch.com/v1/projects/{project ID}/availableNumbers:rentAny' \
-d '{
"regionCode": "US",
"...
0
votes
1
answer
823
views
How to implement TikTok API User Access Token Management v2?
I'm trying to update a TikTok API integration, specifically, the User Access Token Management part, which has recently been updated to V2.
My application is a Ruby on Rails app, and I'm encountering ...
-1
votes
1
answer
336
views
Download File from Dropbox folder in Rails application
I am trying and failing to download a single file from a "open for public" dropbox folder which a 3rd party created for others to use. I am trying to use this within my Ruby On Rails ...
0
votes
2
answers
2k
views
Rails 4 - How to mock the exception with custom response using rspec?
In rails 4, I am using rspec for writing a test cases. Currently I want to mock one service call which raises Exception and returns required(custom) output.
Eg:
allow(RestClient).to receive(:post)....
1
vote
1
answer
1k
views
Ruby 2.7 and TLS 1.3 with RestClient not working
I'm having problems trying to request an endpoint that is using TLS 1.3
require 'base64'
require 'openssl'
require 'rest-client'
auth_payload = {
grant_type: 'client_credentials',
scope: '...
0
votes
1
answer
968
views
Using RSpec to test a Retry RestClient
I'm using Oauth so what I do is store access_token and refresh token at User table, I create some classes to do this. In the Create class I do the normal functionality of the code (create records on ...
0
votes
1
answer
159
views
How to work with Spotify using HTTP requests in Ruby
At first I need to make a new playlist in my spotify account then I need to add some songs and then to change order of the songs in playlist. How can I do this using HTTP requests in ruby with Watir ...
1
vote
1
answer
1k
views
How to send form-data with RestClient, if data received from a hash?
I have an API endpoint that requires data to be sent to it as form-data. I am using RestClient for sending the data. The problem is that I do not manage to give the data for the request in a way, that ...
0
votes
0
answers
175
views
How to authorize to spotify with Ruby + RestClient
I need to authorize and parse some data from my account.
When I try to accest authorize link im getting a set of error which I dont know how to handle.
require 'json'
require 'watir'
require 'bundler'
...
1
vote
0
answers
183
views
Non-blocking Faye Websocket + Eventmachine + RestClient
I have the following code using Eventmachine, Faye Websockets and RestClient:
class FxApi
def self.rates(base_currency = 'USD')
JSON.parse Restclient.get(FX_API_URL + '/latest', { base: ...
0
votes
1
answer
275
views
make a request using curl, equivalent to a REST_CLIENT request
I'm using the following request in Curl
curl -X GET -k -H 'Content-Type: application/json' -H 'Authorization: Bearer XXXXXXX' -H 'RowId: 100' -i 'https://url.xxx/row'
and the request using ...
0
votes
1
answer
584
views
Ruby reverse image search on Yandex using rest-client file upload
I am trying to clone the top answer from this stack overflow question in ruby
Reverse search an image in Yandex Images using Python
require 'rest-client'
require 'pry'
response = RestClient.post '...
0
votes
0
answers
383
views
Ruby POST multipart/form-data results in 302 Found
I am trying to upload a csv file to my endpoint. I tried doing this and resulting in 302 Found.
Tried other solution mentioned here: Multipart POST Ruby HTTPS but same results.
First option using net/...
1
vote
1
answer
477
views
Ruby on Rails: Trying to make multiple API requests based on an array of values. How can I insert these values as parameters into the API URL?
I'm using rest-client (2.1.0-x64-mingw32) with Ruby on Rails (v6.0.3.2).
I'm trying to make multiple API requests based on an array of values.
For example, here is a short array containing the values ...
0
votes
0
answers
298
views
rest-client: How to limit rest request to ask only for the first 5 records?
I am new to Ruby, and to rest-client.
I would like to fetch the first 5 articles from the following endpoint.
How can I adjust my request so the endpoint will fetch only 5 records?
require 'rest-...
0
votes
1
answer
56
views
Not able to get URL/Cookies in Ruby buts its working with Python
I am having a problem in accessing a URL via ruby but it is working with python's requests library.
Here is what I am doing, this link https://www.nseindia.com/get-quotes/derivatives?symbol=SBIN I ...
0
votes
1
answer
527
views
Passing encoded URL query param using RestClient in Ruby giving incorrect result
I am trying to access a private API endpoint that accepts a phone number, including the country code, in the URL query parameters. Because the phone number has to include the "+", the phone ...
0
votes
1
answer
370
views
How to send proxy username and password with RestClient Ruby gem
I'm using RestClient gem for a post request according to the documentation we can add proxy , but in my case proxy URL itself has authentication, how to achieve it with Restclient Gem
RestClient.proxy ...
0
votes
1
answer
335
views
cannot load such file -- restclient/instrumentation
While adding instrumentation tracing to my existing app, I got the error cannot load such file -- restclient/instrumentation
Here's the bulk of the stack dump:
% bundle exec rails console
cannot load ...
-1
votes
1
answer
45
views
Ruby Restclient different double point or astrophobe and is order important
i am new to ruby RestClient. i have search many example of this restclient and in docruby. For me is important while using ruby restclient, to get the data very fast.
But some are not answers, this is ...
0
votes
1
answer
511
views
Adding multiple content type in restclient headers
I am trying to post two types of data to the api. "multipart/form-data" and "application/json".
This is the headers and payload I am passing:
payload = {
:multipart => true,
:user_photo => ...
0
votes
0
answers
517
views
How to use RestClient - Ruby for my situation
I'm trying to use RestClient with Ruby. I got a curl from Postman, but when I try generate my code in Ruby I had a problem.
curl --location --request GET 'https://url?param1=value1¶m2=value2' ...
0
votes
0
answers
2k
views
How to pass form-data with rest-client
I am trying to translate a post request I send to a server with Postman to ruby RestClient.
In Postman, I send a (successful) POST request with a URL with params.
In my headers I have one parameter
...
1
vote
0
answers
780
views
Ruby rest-client gem always causing OpenTimeout
I'm trying to use the API of the Bureau of Labor Statistics, and trying to use the API using curl works perfectly and returns the results almost immediately:
curl -X GET "https://api.bls.gov/...
2
votes
1
answer
3k
views
How could I handle rest-client 500 error response and keep scraping through my loop?
I need to scrape 10k URLs from this website and some of them are out of service (I think... it's an error that does not return the JSON I'm looking for, so rest-client returns 500 Internal Server ...
0
votes
1
answer
811
views
Proper way to upload a doc to FSCrawler for indexing in Elasticsearch
I'm prototyping a Rails application to upload documents to FSCrawler (running the REST interface), to incorporate into an Elasticsearch index. Using their example, this works:
response = `curl -F "...
0
votes
1
answer
101
views
How to use Mailgun with HTTParty in Rails
I want to use Mailgun with HTTParty in Rails:
RestClient.post "https://api:key-###"\
"@api.mailgun.net/v3/###/messages",
from: from_email,
to: to_email,
subject: title,
html: ...
0
votes
1
answer
2k
views
undefined local variable or method `make' for main:Object (NameError)
I got below error on Ubuntu 18 when trying to install rest-client sudo gem install rest-client:
current directory: /var/lib/gems/2.5.0/gems/unf_ext-0.0.7.6/ext/unf_ext
/usr/bin/ruby2.5 -r ./...
2
votes
1
answer
3k
views
Rest-Client gem RoR, Getting SSL wrong version error
I want to build a cli ruby app which sends requests to Rails API server. I wanted to use rest-client gem to do that. Every time i use
RestClient.post
I get the following error
SSL_connect ...
6
votes
2
answers
4k
views
Where should I store the token when calling an API from my Rails app?
I'm writing a library to call a third party API so that it can be used by a Rails app. To authenticate, the API initially uses basic auth to return a token which is used for all other requests. Tokens ...
0
votes
1
answer
36
views
Ruby array.each and RestClient skipping array elements
I've a array of elements and for each element, I've to make a get call using RestClient. However, I see a few of the array elements are being skipped.
total_hosts = []
puts "total_hosts ...
0
votes
1
answer
2k
views
RestClient post request in ruby on rails
RestClient post request
I tried post request couple ways
@user = {name: 'xxxxxx', email: '[email protected]', password: 'qwertyqqq'}
RestClient.post 'http://localhost:4123/api/users?token=<token&...
1
vote
0
answers
27
views
Rest-client ruby gem attached 0 kb file
I'm using rest-client ruby gem to upload an HTML document through an API. Every time I execute my code, the attachment got uploaded with the file name but the file is empty (0 Kb). Below is my Ruby ...
2
votes
1
answer
475
views
Why Rails response takes one minute in development mode?
Can't understand why my rails app become make response ultra-slow - in 1 minute!
As i see total time Rails should be: Views 0.2ms + ActiveRecord 219.5ms + Solr 379.7ms = 599.4ms
But it takes ...
0
votes
0
answers
929
views
How to fix Gem Conflict Error with 2 versions of a dependency without bundler
I am making a discord bot in ruby and am using the rspotify gem. rspotify has rest-client v2.0.2 as a dependency while the library discordrb has rest-client v2.1.0.rc1 as a dependency. When I try to ...
2
votes
1
answer
55
views
How to check for nil on an object?
I do the following call to get a Ruby object, which returns data from Spotify's API:
spotify_track = RSpotify::AudioFeatures.find('3RmAqYZZjiSyMV40hm6rDL')
That returns:
#<RSpotify::...
0
votes
1
answer
235
views
Postman POST works properly; Ruby POST does not. How do I debug the difference?
I need to do a POST request for an API that takes a JSON payload that contains a nested stringified JSON object. I do a GET request to get the string, parse it (twice!) to get the hash, modify one ...
1
vote
1
answer
1k
views
How to convert a cURL multipart/form-data POST request to ruby request using rest-client?
I have to implement the curl POST request listed below in Ruby using Rest-Client so that I can upload a file to my server.
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: ...
0
votes
1
answer
149
views
How do I configure net-ssh so I can fetch data using rest-client through an ssh tunnel?
We have an elasticsearch setup that is only available from a jump box. I want to set up an ssh tunnel so I can query from my laptop or a Docker container.
When I run ssh, either directly or via '...
0
votes
1
answer
656
views
Uploading data via HTTP PUT without multi-part gutter
I'm trying to upload static HTML+friends content to a raw Nexus 3 repository. As far as the documentation goes, the only way to upload files is using HTTP PUT. Sure enough,
curl -v --user 'user:pw' --...
-1
votes
2
answers
290
views
How to refactor ruby rest-client get method
I'm using Rubys rest-client gem to make a call to Google API and want to shorten the url part.
Current code:
class GoogleTimezoneGetter
def initialize(lat:, lon:)
@lat = lat
@lon = lon
...
0
votes
3
answers
1k
views
Failed to install gem rest-client
I am trying to install gem res-client in my redhat linux server.Installed whatever dependencies i found but still not working for me.
Ruby Version:
ruby 2.3.6p384 (2017-12-14 revision 61254) [...
0
votes
0
answers
243
views
Trouble to make a request with httparty
I'm using rest-client to make some request in a API, inside my automation scenarios with cucumber.
I'm trying to change the gem to Httparty but I can not do it.
url_login = "https://mu.com/login"
...
2
votes
0
answers
325
views
POST transfer progress for large file with RestClient for Rails
I need to POST a large file (several GB) from disk to an external API from my Rails 5.2 app. The file can take up to an hour to transfer.
I can POST the file using RestClient, but would like to ...
0
votes
2
answers
2k
views
How do I convert this curl command to Ruby rest-client put request?
I have this curl command which I need to covert to PUT request
curl https://example.com/api/v2/students/id.json \
-d '{"student":{"description":{"body":"Adding a new test description"}}}' \
-H "...
0
votes
1
answer
472
views
How to send api request with authentication in ruby
I have this curl command to send api request with authentication. I am writing a test using airborne where I need to send an api request inside the test.
curl command
curl https://example.com/api/v2/...
2
votes
2
answers
536
views
How to convert a CURL request to Ruby Gem HTTPClient
I am trying to convert this CURL request:
curl \
-F 'slideshow_spec={
"images_urls": [
"<IMAGE_URL_1>",
"<IMAGE_URL_2>",
"<IMAGE_URL_3>"
],
"...
0
votes
1
answer
862
views
Ruby rest-client 401 Unauthorized after post of data
I'm new to using the rest-client. I know I'm missing something, but I am trying to do the following:
Post to a login endpoint to authenticate
After authentication, post csv text to another endpoint ...
0
votes
1
answer
2k
views
Post request not working with Rest-Client but It's OK with Faraday and Postman
I have a POST request to login a testing site
This request works fine with cURL or Faraday gem, but not working well with rest-client gem.
1) With cURL
curl -X POST \
'https://mysite.vn/api/tokens?...