I am pretty new with Rails and REST. I want to consume REST API in Rails. I found an easy and standard way with ActiveResource.
API which I want to consume is: https://api.pinterest.com/v2/popular
While accessing this API directly, gives response as: {"message": "Please upgrade your app!", "error": "Authentication failed: Please upgrade your app!"}
Hence, I want same result when I consume it from RAILS.
To do the same, I generated one model as Popular and modified its code as:
class Popular < ActiveResource::Base
self.site = "https://api.pinterest.com/v2/popular"
self.format = :json
end
Then, I generated a controller as Populars and modified its code as:
class PopularsController < ApplicationController
def index
@popular = Popular.all
render :json => @popular
end
end
Then in routes.rb, I added
resources :populars
while running "http://localhost:3000/populars", it shows 'null' in browser. While expected result is {"message": "Please upgrade your app!", "error": "Authentication failed: Please upgrade your app!"}
Please guide, where I am running wrong.
Please provide Specific guidelines to consume HTTPS REST APIs in Rails. How to consume them with OAuth?
Is there any other better way than consuming it via ActiveResource?