httparty

OpenSSL::SSL::SSLError: hostname does not match the server certificate

。_饼干妹妹 提交于 2019-12-01 06:02:48
All of sudden today morning my HTTP client (HTTParty) threw an error OpenSSL::SSL::SSLError: hostname does not match the server certificate Firstly I'm not able to understand which so today we have been make that api call almost all day number times from past 2 years without any issue Secondly I don't understand how do I solve it since it internal to HTTParty The only thing I know of is that I cant set SSL_CERT_FILE in ENV but as said I already have ROOT CA listed in my /etc/ssl/certs ( SSL_CERT_DIR ) Here my output irb(main):001:0> require "openssl" => true irb(main):002:0> puts OpenSSL:

OpenSSL::SSL::SSLError: hostname does not match the server certificate

你说的曾经没有我的故事 提交于 2019-12-01 03:26:17
问题 All of sudden today morning my HTTP client (HTTParty) threw an error OpenSSL::SSL::SSLError: hostname does not match the server certificate Firstly I'm not able to understand which so today we have been make that api call almost all day number times from past 2 years without any issue Secondly I don't understand how do I solve it since it internal to HTTParty The only thing I know of is that I cant set SSL_CERT_FILE in ENV but as said I already have ROOT CA listed in my /etc/ssl/certs ( SSL

Changing Content-Type to JSON using HTTParty

允我心安 提交于 2019-11-30 17:33:28
I am trying to use Ruby on Rails to communicate with the Salesforce API. I can fetch data easily enough but I am having problems posting data to the server. I am using HTTParty as per Quinton Wall's post here: https://github.com/quintonwall/omniauth-rails3-forcedotcom/wiki/Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com but all I seem to be able to get from the salesforce server is the error that I am submitting the body as html {"message"=>"MediaType of 'application/x-www-form-urlencoded' is not supported by this resource", "errorCode"=>"UNSUPPORTED_MEDIA_TYPE"} the

Memory issues with HTTParty and download large files

回眸只為那壹抹淺笑 提交于 2019-11-30 10:02:39
Is this going to cause memory issues with Ruby. I know Open-URI writes to a TempFile if the size goes over 10KB. But will HTTParty try and save the whole PDF to memory before it writes to TempFile? src = Tempfile.new("file.pdf") src.binmode src.write HTTParty.get("large_file.pdf").parsed_response You can use Net::HTTP. See the documentation (in particular the section titled "Streaming Response Bodies"). Here's the example from the docs: uri = URI('http://example.com/large_file') Net::HTTP.start(uri.host, uri.port) do |http| request = Net::HTTP::Get.new uri.request_uri http.request request do

How to use basic authentication with httparty in a Rails app?

不羁的心 提交于 2019-11-30 04:09:18
The command line version of 'httparty' with basic authentication works simple and great: httparty -u username:password http://example.com/api/url But now I'm looking for the way I can add the basic auth to a HTTParty.get call from within a Rails app. First of all, for testing purposes, I want to hard code the login credentials in the Controller. Just to make sure it works. But I can't find any documentation or examples how you can pass these along. A HTTParty.get without credentials works fine: @blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json") But I don't see how I can

Changing Content-Type to JSON using HTTParty

早过忘川 提交于 2019-11-30 01:55:12
问题 I am trying to use Ruby on Rails to communicate with the Salesforce API. I can fetch data easily enough but I am having problems posting data to the server. I am using HTTParty as per Quinton Wall's post here: https://github.com/quintonwall/omniauth-rails3-forcedotcom/wiki/Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com but all I seem to be able to get from the salesforce server is the error that I am submitting the body as html {"message"=>"MediaType of 'application/x

Using rails to consume web services/apis

假装没事ソ 提交于 2019-11-29 22:33:22
I'm new to the rails world and am trying to build a app to simply allow me to search things on Amazon and such sites based on the users input. I've done a little reasearch and it seems the httparty gem is a good place to start? The documents ive found so far though are not the best. They don't really give me a lot of information (where to put the code etc). Are there any existing tutorials out there or code examples that I can either use or take a look at to give me a better idea of how this thing works? I'm working on an app like this right now, so let me offer a few thoughts. First, if you

POSTing large amounts of data with HTTParty

允我心安 提交于 2019-11-29 15:52:55
I'm using HTTParty to post information to a server using the following code: this_component = {"name" => "something", "ip" => "localhost", "logs" => logs_to_push} payload = {"payload" => JSON.dump(this_component)} response = JSONClient.post("http://localhost:8080/log", :body => '', :query => payload) The problem is that I get a Connection reset by peer (Errno::ECONNRESET) message when the POST actually executes, which I'm pretty sure is caused by my payload being too large (as logs_to_push is an array with ~200 log lines in it). How would I refactor the above so that I could push this data

Memory issues with HTTParty and download large files

时光毁灭记忆、已成空白 提交于 2019-11-29 14:57:51
问题 Is this going to cause memory issues with Ruby. I know Open-URI writes to a TempFile if the size goes over 10KB. But will HTTParty try and save the whole PDF to memory before it writes to TempFile? src = Tempfile.new("file.pdf") src.binmode src.write HTTParty.get("large_file.pdf").parsed_response 回答1: You can use Net::HTTP. See the documentation (in particular the section titled "Streaming Response Bodies"). Here's the example from the docs: uri = URI('http://example.com/large_file') Net:

How to use basic authentication with httparty in a Rails app?

♀尐吖头ヾ 提交于 2019-11-29 01:20:22
问题 The command line version of 'httparty' with basic authentication works simple and great: httparty -u username:password http://example.com/api/url But now I'm looking for the way I can add the basic auth to a HTTParty.get call from within a Rails app. First of all, for testing purposes, I want to hard code the login credentials in the Controller. Just to make sure it works. But I can't find any documentation or examples how you can pass these along. A HTTParty.get without credentials works