rest-client

How to send multiple asynchronous requests to different web services?

主宰稳场 提交于 2019-12-03 05:10:55
问题 I need to send multiple requests to many different web services and receive the results. The problem is that, if I send the requests one by one it takes so long as I need to send and process all individually. I am wondering how I can send all the requests at once and receive the results. As the following code shows, I have three major methods and each has its own sub methods. Each sub method sends request to its associated web service and receive the results;therefore, for example, to receive

Ruby rest-client file upload as multipart form data with basic authenticaion

百般思念 提交于 2019-12-03 03:34:05
I understand how to make an http request using basic authentication with Ruby's rest-client response = RestClient::Request.new(:method => :get, :url => @base_url + path, :user => @sid, :password => @token).execute and how to post a file as multipart form data RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb') but I can't seem to figure out how to combine the two in order to post a file to a server which requires basic authentication. Does anyone know what is the best way to create this request? robustus How about using a RestClient::Payload with RestClient::Request ...

How to upload a file using a rest client for node

落爺英雄遲暮 提交于 2019-12-03 01:36:10
I have a REST client on node, and I'm trying to upload pdf a file to another REST webserver which provides the ability to parse my pdf and extract some data. Basically it is a service. The npm package that I use is: https://www.npmjs.com/package/node-rest-client . If there are other rest clients, I can use those as well. The rest api I need to use is described below: POST / ; Uploads a new PDF document via a form <br> POST /file ; Uploads a new PDF document via bytestream The question is how to upload the file. Also, I would like to see how to store the file at the other end. sam100rav You can

How to debug/display request sent using RestClient

你说的曾经没有我的故事 提交于 2019-12-03 01:02:27
I am trying to use RestClient to access a webservice using post method. I am sending the authorization token as specified but I am still getting a 403 status error which means I am forbidden to use that api. Is there any way that I can see the request being sent with http post so that I can verify the headers? I am not able to find any example or any documentation which mentions as to how to do that? My code is similar to this : token = get_token response = RestClient.post "https://api-dev.xxx.com/software/services/search/ABC", :authorization => "Bearer #{token}" You could try enabling

How to handle exceptions with Ruby Rest-Client

余生长醉 提交于 2019-12-02 23:22:43
I recently switched from Ruby's Net:HTTP class to rest-client 1.6.7. I find it a lot easier to form requests, but unlike Net:HTTP request, when rest-client gets anything other than a 200, the request dies. I've tried putting a breakpoint directly after the RestClient.get, and it never gets hit - so I'm doing something wrong. def get_member_using_card resource = "#{@settings_app_uri}api/v1/card/#{self.member_card_num}?token=#{@settings.api_key}" response = RestClient.get resource if response.code == 200 card = JSON.parse(response.body) self.customer_id = card['card']['customer_id'] else return

How to send multiple asynchronous requests to different web services?

微笑、不失礼 提交于 2019-12-02 18:23:33
I need to send multiple requests to many different web services and receive the results. The problem is that, if I send the requests one by one it takes so long as I need to send and process all individually. I am wondering how I can send all the requests at once and receive the results. As the following code shows, I have three major methods and each has its own sub methods. Each sub method sends request to its associated web service and receive the results;therefore, for example, to receive the results of web service 9 I have to wait till all web services from 1 to 8 get completed, it takes

API POST with array using HTTP gem (or RestClient)

此生再无相见时 提交于 2019-12-02 17:43:40
问题 I'm having trouble with this api and can't seem to get over the hump. Using the HTTP gem (though I'm flexible and can use RestClient if that gets me an answer quicker!). Anyway, I'm having trouble posting an array. everything else is good, I just can't figure out this "itemsarray" in the printaura api found here in the addorder method: PrintAura API I'm running this: def self.submitorder req = HTTP.post("https://api.printaura.com/api.php", :json => { :key => APIKEY, :hash => APIHASH, :method

Rails: External API Integration using RestClient (undefined local variable or method `user')

十年热恋 提交于 2019-12-02 15:58:40
问题 I am building a digital library, and I have completed a lot of the functionalities needed. I am currently having an issue with integrating the digital library with a Learning Management System (LMS). I already have an admin authentication system for the digital library using the Devise gem . My goal is to allow users who want to access the digital library to login to the digital library using their Learning Management System (LMS) credentials (username and password). I have been provided with

Rails: External API Integration using RestClient (undefined local variable or method `user')

佐手、 提交于 2019-12-02 11:51:27
I am building a digital library, and I have completed a lot of the functionalities needed. I am currently having an issue with integrating the digital library with a Learning Management System (LMS). I already have an admin authentication system for the digital library using the Devise gem . My goal is to allow users who want to access the digital library to login to the digital library using their Learning Management System (LMS) credentials (username and password). I have been provided with the Login API endpoint and other needed parameters of the Learning Management System (LMS) , and I

API POST with array using HTTP gem (or RestClient)

▼魔方 西西 提交于 2019-12-02 07:51:42
I'm having trouble with this api and can't seem to get over the hump. Using the HTTP gem (though I'm flexible and can use RestClient if that gets me an answer quicker!). Anyway, I'm having trouble posting an array. everything else is good, I just can't figure out this "itemsarray" in the printaura api found here in the addorder method: PrintAura API I'm running this: def self.submitorder req = HTTP.post("https://api.printaura.com/api.php", :json => { :key => APIKEY, :hash => APIHASH, :method => "addorder", :businessname => "this is a secret too", :businesscontact => "thats a secret", :email =>