rest-client

Ruby client for 2-way ssl authentication

孤人 提交于 2019-12-08 10:00:25
问题 I have java web service supports 2-way ssl auth . So I have client key store ( client.p12 ) with server certificate in trusted store and server key store with client cert in trusted store. I can easily call my service using browser or postman (just need importing client.p12 in browser certificates management) but I have problems with ruby client. My current version: require 'rest_client' p12 = OpenSSL::PKCS12.new(File.read('client.p12'), 'password') client = RestClient::Resource.new('https:/

How to push notification from rest client for testing purpose

て烟熏妆下的殇ゞ 提交于 2019-12-07 19:03:29
问题 Hi I am trying to push the notification from rest client to android app. I am doing like below - URL - https://android.googleapis.com/gcm/send Method - POST Headers - Authorization: my_server_key I always get this message Status Code: 401 Unauthorized Alternate-Protocol: 443:quic,p=0.002 Cache-Control: private, max-age=0 I am not sure what I am missing & last I am using correct server api key. Please assist & thanks in advance. 回答1: Push notification uses Web Socket . You cannot do this using

RestClient.get returning certificate verify failed

给你一囗甜甜゛ 提交于 2019-12-07 06:34:54
问题 I am trying hit an internal testing API server using RestClient and Ruby v. 2.2.1. This is essentially the code: url = "https://10.10.0.10/thing/i/want/to/get" header = { :content_type => "application/json", :"x-auth-token" => "testingtoken" } response = RestClient.get url, header This is the failure message I get: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (RestClient::SSLCertificateNotVerified) If I'm reading this right, it looks like

Rails RestClient POST request failing with “400 Bad Request”

五迷三道 提交于 2019-12-07 05:25:56
问题 Looking at the docs there aren't any good examples of how to make a POST request. I need to make a POST request with a auth_token parameter and get a response back: response = RestClient::Request.execute(method: :post, url: 'http://api.example.com/starthere', payload: '{"auth_token" : "my_token"}', headers: {"Content-Type" => "text/plain"} ) 400 bad request error: RestClient::BadRequest: 400 Bad Request from /Users/me/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0/lib

Authentication headers using Rest Client Ruby Gem

大城市里の小女人 提交于 2019-12-07 01:52:15
问题 I have already created a basic authentication key, now I am just trying to utilize it. I have tried a few different variations, but none seem to show Authorization in the request headers. $auth = 'Basic cmFtZXNoQHVzYW1hLmNvbTpyYW1lc2h1JEBtcA==' @response = resource.post('Authorization' => $auth) nor @response = resource.post(:authorization => $auth) nor @response = resource.post(:Authorization => $auth) nor @response = resource.post(:content_type => :json, :accept => :json, :headers => {

Rails: How to send file from S3 to remote server

▼魔方 西西 提交于 2019-12-06 07:10:14
I've been hunting around and can't seem to find a good solution for this. My Rails app stores it's files in Amazon S3. I now need to send them to a remote (3rd party) service. I'm using RestClient to post to the 3rd party server like this: send_file = RestClient::Request.execute( :method => :post, :url => "http://remote-server-url.com", :payload => File.new("some_local_file.avi", 'rb'), :multipart => true, etc.... ) It works for local files, but how can I send a remote file from S3 directly to this 3rd party service? I found an answer here where someone was using open-uri: ruby reading files

Omniauth + Google + Faraday + Behind the proxy = how setup proxy?

社会主义新天地 提交于 2019-12-06 05:28:01
My production server is Ubuntu 12 . I'm using Devise + OmniAuth to handle the Google authentication. But when Google returns a control to my application I get an error "Network is unreachable" . I assume it's because of server is behind the proxy. Here's error description: ------------------------------- Request: ------------------------------- * URL : http://efiling.uipv.org/users/auth/google_oauth2/callback?state=f4eaca9fbed2a77c0baac50cdbdccab7eee671179bb8fc43&code=4/YRcyYZzkrfNh8mEBbenxaxyx5EjN.4snirEA-93MXOl05ti8ZT3a9mXdIcgI * IP address: 213.160.144.239 * Parameters: {"state"=>

passing json data in elasticsearch get request using rest-client ruby gem

核能气质少年 提交于 2019-12-06 00:13:10
How do I execute the below query(given in doc ) using rest client. curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{ "query" : { "term" : { "user" : "kimchy" } } } ' I tried doing this: q = '{ "query" : { "term" : { "user" : "kimchy" } } } ' r = JSON.parse(RestClient.get('http://localhost:9200/twitter/tweet/_search', q)) This threw up an error: in `process_url_params': undefined method `delete_if' for #<String:0x8b12e18> (NoMethodError) from /home/socialapps/.rvm/gems/ruby-1.9.3-p194/gems/rest-client-1.6.7/lib/restclient/request.rb:40:in `initialize' from /home/socialapps/.rvm

`Required session does not exist` error while using REST api of Quickblox

て烟熏妆下的殇ゞ 提交于 2019-12-05 21:43:39
I am using REST api of Quickblox. but everytime , i am getting response : {"errors": { "base": ["Required session does not exist"] }} And i am using below api : url : http://api.quickblox.com/users.json Data & header is : curl -X POST \ -H "Content-Type: application/json" \ -H "QuickBlox-REST-API-Version: 0.1.0" \ -H "QB-Token: cf5709d6013fdb7a6787fbeb8340afed8aec4c69" \ -d '{"user": {"login": "xyz", "password": "xyz@123", "email": "xyz@domain.com", "external_user_id": "68764641", "facebook_id": "87964654", "twitter_id": "132132", "full_name": "test 1234", "phone": "87654351", "website": "",