Record not found errors when retrieving activity streams

917 views
Skip to first unread message

Robert Vizza

unread,
Mar 14, 2015, 7:29:23 PM3/14/15
to strav...@googlegroups.com
I'm using the Ruby V3 API to access activities and then activity streams for users. Most of the time the process works fine but with one user in particular I am getting the following error when retrieving activity streams for known activity IDs:
{"message":"Record Not Found","errors":[]}

Abbreviated code example follows:
      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

Apparently valid activity IDs are returned from list_athlete_activities however when requesting the streams from those activities, a StravaError is raised. Following is an example output in this circumstance. Note that valid looking IDs in the output below have been replaced with xxx.
[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]

Lastly, I request view_private during initial authentication for the user. Thanks in advance for any help on this one.

Robert

Robert Vizza

unread,
Mar 16, 2015, 1:00:42 PM3/16/15
to strav...@googlegroups.com
In case someone else faces this issue, it turns out that these are user entered rides and therefore the streams are not present. Of course, that's probably what the "manual"=>true hash meant...Ah well, stupid mistake...
Reply all
Reply to author
Forward
0 new messages