Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble adding new alarms

I've been reading the docs over at https://dev.fitbit.com/docs/devices/ and using the library available at https://github.com/whazzmaster/fitgem.

 

I'm trying to set an alarm for "13:00-04:00"

 

The response I get back is:

 

301
Net::HTTPMovedPermanently
    server: nginx
    x-ua-compatible: IE=edge,chrome=1
    location: http://api.fitbit.com/1/user/-/devices/tracker/alarms.json
    connection: close, close
    content-length: 0
    date: Tue, 25 Aug 2015 15:56:56 GMT
    x-frame-options: SAMEORIGIN

The odd thing here I find is that the redirected URL does NOT have a tracker ID in it

My post body:

{
  "enabled": "true",
  "time": "14:00-04:00",
  "recurring": "false",
  "weekDays": [

  ]
}

For the booleans, I've tried both "true" and true.

Modified from the original API:

    def add_alarm(opts)
      device_id = opts[:device_id]
      post("/1/user/#{@user_id}/devices/tracker/#{device_id}/alarms.json", opts)
    end
Best Answer
0 Votes
2 REPLIES 2

You need to use HTTPS. https://api.fitbit.com

Best Answer
0 Votes

From what I can tell, I am using HTTPS:

 

      def consumer
        @consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
          :site => 'https://api.fitbit.com',
          :authorize_url => 'https://www.fitbit.com/oauth/authorize',
          :proxy => @proxy
        })
      end

      def access_token
        @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
      end

The request is made using the access_token.  If I understand everything here, my requests are being made over HTTPS.

 

I'm starting to feel like I need to reimplement the entire library and start with OAuth, but I wanted to see if this is a quick fix first before I do that.

Best Answer
0 Votes