rest-client

Rails RestClient POST request failing with “400 Bad Request”

限于喜欢 提交于 2019-12-05 11:16:04
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/restclient/abstract_response.rb:74:in `return!' from /Users/me/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems

RestClient.get returning certificate verify failed

天涯浪子 提交于 2019-12-05 08:34:41
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 Ruby couldn't accept the SSL security certificate. This call works in the Chrome app Postman, but in order

Authentication headers using Rest Client Ruby Gem

跟風遠走 提交于 2019-12-05 08:11:37
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 => { 'Authorization:' => $auth }) Unfortunately I am not finding a lot of info in the rdoc that can help me

Handle Connection and Read Timeouts for RestClient calls in android

拈花ヽ惹草 提交于 2019-12-05 03:09:37
问题 I have a RestService interface with many rest calls which I am using throughout my application. I am setting timeouts for handling connection and read-timeouts ClientHttpRequestFactory httpFactory = myRestService.getRestTemplate().getRequestFactory(); if(httpFactory!=null) { if(httpFactory instanceof SimpleClientHttpRequestFactory) { ((SimpleClientHttpRequestFactory)httpFactory).setConnectTimeout(10*1000); ((SimpleClientHttpRequestFactory)httpFactory).setReadTimeout(30*1000); } else if

Windows phone 7: how to post tweet to twitter

可紊 提交于 2019-12-04 21:35:46
Currently i am working on sharing functionality from windows phone. My purpose is to share the status of the user to Facebook and the Twitter from my windows phone App. I completed the Facebook sharing successfully and now i m trying to share the status (120 Words tweet only) to twitter. I completed the Authentication with Twitter account using this . When i try to post the tweet to the twitter account after am logged in to the account using this tweet button click event, private void btnPostTweet_Click(object sender, RoutedEventArgs e) { var credentials = new OAuthCredentials { Type =

Spring Rest Client Exception Handling

試著忘記壹切 提交于 2019-12-04 21:05:59
问题 I am using spring RestTemplate to consume rest services(exposed in spring rest). I am able to consume success scenarios. But for negative scenarios, service returns error messages and error codes. I need to show those error messages in my web page. For e.g. for invalid request, service throws HttpStatus.BAD_REQUEST with proper messages. If i put try-catch block it goes to catch block and I am not able to get ResponseEntity object. try { ResponseEntity<ResponseWrapper<MyEntity>> responseEntity

ruby rest-client: make it never timeout?

南笙酒味 提交于 2019-12-04 16:58:04
问题 I am trying to use ruby rest-client to upload a large number of images to a site that I'm writing. My code looks like: RestClient.post url, :timeout => 90000000, :open_timeout => 90000000, :file_param => file_obj However, I am getting this error: RestClient::RequestTimeout: Request Timeout from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.1/lib/restclient/request.rb:174:in `transmit' from /Library/Ruby/ But when I look at the server log Completed in 61493ms (View: 2, DB: 1) | 201 Created So

Spring Rest Client Exception Handling

白昼怎懂夜的黑 提交于 2019-12-04 03:13:56
I am using spring RestTemplate to consume rest services(exposed in spring rest). I am able to consume success scenarios. But for negative scenarios, service returns error messages and error codes. I need to show those error messages in my web page. For e.g. for invalid request, service throws HttpStatus.BAD_REQUEST with proper messages. If i put try-catch block it goes to catch block and I am not able to get ResponseEntity object. try { ResponseEntity<ResponseWrapper<MyEntity>> responseEntity = restTemplate.exchange(requestUrl, HttpMethod.POST, entity, new ParameterizedTypeReference

Stubbing RestClient response in RSpec

こ雲淡風輕ζ 提交于 2019-12-04 02:30:22
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 responses so I don't have to invoke an actual HTTP call. My application code is... post '/user/create' do