For API call I've tried..
In RestClient
Works but is wrong:
response = RestClient::Request.execute(
method: :get,
url: 'https://api.data.charitynavigator.org/v2/Organizations?app_id=2b1ffdad&app_key=XXXX',
)
Doesn't Work (403: Forbidden):
response = ::RestClient::Request.execute(method: :get, url: 'https://api.data.charitynavigator.org/v2/Organizations?app_id=2b1ffdad',
headers: {app_key: 'XXXX'})
In HTTParty
Also doesn't work (Authentication parameters missing):
require 'rubygems'
require 'httparty'
class Charity
include HTTParty
base_uri 'https://api.data.charitynavigator.org/v2/'
def posts
headers = {
"app_id" => "2b1ffdad",
"app_key" => "XXXX"
}
self.class.get("/Organizations/",
:headers => headers
)
end
end
charity = Charity.new
puts charity.posts
For reference: https://charity.3scale.net/docs/data-api/reference
Is it syntax? I've also looked into Faraday but ran into similar issues there. Many 3rd party API examples with rails seem to be using long outdated APIs so it's been hard piecing everything together.
Any insight would be greatly appreciated. Really want to understand this.