{"message":"Record Not Found","errors":[]} response = HTTParty.post("https://www.strava.com/oauth/token",
:query => { client_id: ENV['STRAVA_CLIENT_ID'], client_secret: ENV['STRAVA_CLIENT_SECRET'], code: self.code })
unless response["access_token"].blank?
strava_client = Strava::Api::V3::Client.new(access_token: response["access_token"])
unless strava_client.blank?
activities = strava_client.list_athlete_activities( after: start_date.to_time.to_i, before: end_date.to_time.to_i )
unless activities.blank?
activities.each do |acty|
unless acty["id"].blank? or acty["type"] != "Ride" or local_start_time < start_date or local_start_time > end_date
begin
streams = strava_client.retrieve_activity_streams( acty["id"], "latlng,distance,altitude,velocity_smooth,cadence,heartrate,watts,temp", series_type: "time" )
# Process streams here
rescue Strava::Api::V3::StravaError => e
Rails.logger.error( "Error retrieving activity #{acty} from Strava" )
Rails.logger.error( e.message )
Rails.logger.error( e.backtrace.inspect )
end
end
end
else
Rails.logger.warn "Warning message"
end
else
Rails.logger.warn "Warning message"
end
else
Rails.logger.error "Error message"
end[DEBUG] Args: {:after=>1425772800, :before=>1426291200, "access_token"=>"xxx"}
[ERROR] Error retrieving activity {"id"=>xxx, "resource_state"=>2, "external_id"=>nil, "upload_id"=>nil, "athlete"=>{"id"=>xxx, "resource_state"=>1}, "name"=>"spin", "distance"=>24140.2, "moving_time"=>3000, "elapsed_time"=>3000, "total_elevation_gain"=>0.0, "type"=>"Ride", "start_date"=>"2015-03-12T22:57:53Z", "start_date_local"=>"2015-03-12T15:57:53Z", "timezone"=>"(GMT-08:00) America/Los_Angeles", "start_latlng"=>nil, "end_latlng"=>nil, "location_city"=>nil, "location_state"=>nil, "location_country"=>"United States", "start_latitude"=>nil, "start_longitude"=>nil, "achievement_count"=>0, "kudos_count"=>8, "comment_count"=>0, "athlete_count"=>1, "photo_count"=>0, "map"=>{"id"=>"xxx", "summary_polyline"=>nil, "resource_state"=>2}, "trainer"=>false, "commute"=>false, "manual"=>true, "private"=>false, "flagged"=>false, "gear_id"=>nil, "average_speed"=>8.047, "max_speed"=>0.0, "device_watts"=>false, "truncated"=>nil, "has_kudoed"=>false} from Strava - skipped
[ERROR] {"message":"Record Not Found","errors":[]} [HTTP 404]