I'm trying to use the Pocket API to authorize my application. So I'm using Nestful to send HTTP requests. And everytime I try sending a request I get a 400 Bad Request. The Pocket documentation says that it could be that it's either a missing consumer key or a missing redirect url.

But now I'm looking at the network tab in Chrome and it says that there is a 500 Internal Service Error. What are these things, and how can I fix them?

My code:

require "nestful"
require "sinatra"
require "uri"

get '/' do
  params = {
    :consumer_key => '******************************', 
    :redirect_uri => 'http://localhost:4567/callback'
  }    

  response = Nestful.post 'https://www.getpocket.com/v3/oauth/request',
                :params => params,   
                :format => :json
 response.body
 response.headers

end

get '/callback' do
  "hello world"
end
有帮助吗?

解决方案

So I got help on my problem. It turns out that params was already a hash, and so I did not need to say :params => params because that would be redundant.

Before

response = Nestful.post 'https://www.getpocket.com/v3/oauth/request',
            :params => params,   
            :format => :json

After

response = Nestful.post 'https://getpocket.com/v3/oauth/request',
                params,   
                :format => :json
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top