rest-client

Ruby - Uploading a file using RestClient post

寵の児 提交于 2020-01-14 19:56:08
问题 I have a cURL that I am trying to translate into Ruby. the cURL is this: curl -i -k -H "Accept: application/json" -H "Authorization: token" -H "Content-Type: image/jpeg" -H "Content-Length: 44062" --data-binary "gullfoss.jpg" http://www.someurl.com/objects My Ruby code is this: image = File.read('uploads/images/gullfoss.jpg') result = RestClient.post('http://www.someurl.com/objects',image,{'upload' => image, 'Accept' => 'application/json', 'Authorization' => 'token', 'Content-Type' => 'image

How to correctly share JAX-RS 2.0 client

余生长醉 提交于 2020-01-14 07:03:31
问题 To give a little context to my issue... I have a Java EE web application (as a UI / client) that accesses services for data / business logic via a REST interface using the JAX-RS 2.0 client API (Resteasy implementation). Currently I inject a new JAXRS Client instance per request using a RequestScoped CDI managed bean, the thinking being that the client app may call multiple backend resources per request and I reuse the same JAXRS Client for the whole request (although I read somewhere this

Not getting JSON response using content-type application/JSON iOS

久未见 提交于 2020-01-12 10:48:27
问题 I have been provided with a REST service from my customer for which I should get JSON response for my iOS code.I am using content-type as "application/json" but somehow it is taken as "text/html" by default. I cross checked this in a REST client in my Mozilla browser using "application/json" for the content-type in header section and I could see the proper response.On using the below code, I am getting a 400 error from the server. I could always see "text/html" as being used as part of the

How to send a post request to the RESTserver api in php-Codeigniter?

你。 提交于 2020-01-12 07:34:09
问题 I've been trying to make a POST request in my CodeIgniter RestClient controller to insert data in my RestServer, but seems like my POST request is wrong. Here is my RestClient POST request in controller: $method = 'post'; $params = array('patient_id' => '1', 'department_name' => 'a', 'patient_type' => 'b'); $uri = 'patient/visit'; $this->rest->format('application/json'); $result = $this->rest->{$method}($uri, $params); This is my RestServer's controller: patient function visit_post() {

How to Properly Close Raw RestClient When Using Elastic Search 5.5.0 for Optimal Performance?

不想你离开。 提交于 2020-01-11 09:16:31
问题 Am using a Spring Boot 1.5.4.RELEASE Microservice to connect to an ElasticSearch 5.5.0 instance using the low level Rest Client that ElasticSearch provides. pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> </parent> <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org

Groovy RestClient with many connections

北城余情 提交于 2020-01-05 14:05:26
问题 Using Groovy RestClient I am getting the following exception: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated. Make sure to release the connection before allocating another one. As I understand that one connection has not released, so I cannot make another one. What are the possible solutions? Make new RestClient for every call? Or maybe there is some pool? Thanks! 回答1: By default the REST Client uses the BasicClientConnManager which only

Rails: How to send file from S3 to remote server

女生的网名这么多〃 提交于 2020-01-02 15:38:22
问题 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

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

血红的双手。 提交于 2020-01-02 08:08:54
问题 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

Stubbing RestClient response in RSpec

江枫思渺然 提交于 2020-01-01 08:27:49
问题 I have the following spec... describe "successful POST on /user/create" do it "should redirect to dashboard" do post '/user/create', { :name => "dave", :email => "dave@dave.com", :password => "another_pass" } last_response.should be_redirect follow_redirect! last_request.url.should == 'http://example.org/dave/dashboard' end end The post method on the Sinatra application makes a call to an external service using rest-client. I need to somehow stub the rest client call to send back canned

Getting ssl.SSLHandshakeException when using REST client with header but works fine with PostMan

折月煮酒 提交于 2019-12-29 07:14:12
问题 I have an external REST resource with below details: The URL: abc.com/orders (the domain is with https ) I need to pass UserID as an HTTP header with key "user" value is "abcd" This would return an JSON response I am using below Java code for this: try { Client client = Client.create(); WebResource webResource = client.resource("abc.com/orders"); ClientResponse response = webResource.header("user", "abcd").accept("application/json") .get(ClientResponse.class); if (response.getStatus() != 200)